0
votes

I'm new to CRM but I'm finding my feet quickly.

I want to set a default value in a new record - easy enough to do with business rules, however, I need to incorporate a lookup to other records as well.

Basically, I want my "storeID" field to be a six digit number like 300401. I need this number to be made of the 4 digit post (zip) code (Australia) and a two digit sequential number. In my case, I am the only store in postcode 3004, but if I was the second store to join the business my store ID would be 300402.

Assuming the postcode field is set to be required on my entity, my logic will be:

  • var pCode = postcode
  • var seqNo = 1
  • if not exists record with storeID = pCode+seqNo then storeID = pCode+seqNo
  • else loop until not exists record with storeID = pCode+seqNo with the step being seqNo + 1 then use the stepped pCode+right('00' + seqNo, 2) as the storeID

I'm assuming this is too complex for the Business Rules GUI, but what code customisations do I have - particularly with querying existing records to get that sequence number?

Many thanks,

Warren

1
based on your question I updated the tags, you are using CRM 2013, but this can be relevant also for CRM 2011 - Guido Preite

1 Answers

0
votes

Since you are using CRM 2013 this could likely be a nice solution:

http://niiranen.eu/crm/2013/12/auto-numbering-workflows-real-time-vs-asynchronous/

However there are also a number of add-ons that can be found for both CRM 2011 and CRM 2013 by searching for "CRM Autonumber".