So, ideally this would result in:
Master Record A
Child 1
Child 2
Child 3
Master Record B
Child 1
Child 2....
Where the numerical identifier in the child record was in a unique field.
Any ideas?
Thanks to you all
7 respuestas
Brian,
If you need the child records to dynamically obtain a number AND to be updated if one was deleted, you would need an Apex Trigger. (You can't kick off a WFR or process after a record delete.)Otherwise, I would first create a roll-up summary field on the master object that would use COUNT() do store the amount of child records. Then, create a WFR/Process on the Child object to update it's number field based on the current value of that roll-up summary field. Something like
TEXT(Parent__r.My_Rollup__c + 1)
Also have to decide if you want this as the Name field of the record vs a custom number field.
The reason why this wouldn't work exactly when you delete a record is that the newly created child record would be numbered correctly (4 if it the 4th child record since the roll-up summary would update), but the old 4th record would still be labeled as 4 even though it was now 3.