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