+ Start a Discussion
Blake TanonBlake Tanon 

Numbering Records



I've searched far and wide and spent a good time thinking about the best way to solve the below problem, but I'm either not sure how to do them or which would be the best solution.


I have a couple of projects I'm working on that require an auto numbering of some sort, but not the auto-numbering field out of the box.  I need child records of a partent to be numbered 1 though n based onspecific critiera, a date field and 2 lookups (date__c, contact__c, fund__c) - if there are multiple records on the same day with the same contact/fund they should be the same number.  That being said, here are the solutions I've come to...


1)  Create a workflow that runs off of a count rollup, assigning the number +1 to the new child. 

Problem: not dynamic enough, not enough control on the groupings 


2) Use SQL to number the records, this would require a daily export/import to assign the numbers - while this wouldn't be a huge burden on our api I would prefer not to use this method


3) Some how do this in java - I don't know java


4) use a trigger - I could firgure this out, but I don't think it's the best way.


5) use batch apex - not sure how to do this


Any ideas?

I think trigger is the good way.just write a SOQL query if two lookups and date field is same then assign the same number.

any questions let me know.