You need to sign in to do that
Don't have an account?
Gwirizanani Sinoia
appending the parent record number to the child record and count the child records againt the parent
Hi all,
i have business case where I have two objects in a masterdetail relationship. My objective is to be able to append parent record auto number field to the child record number
ie Parent record number Pr01 and child record number 1. The main thing is the child record number is a count of how many child records are associated with that particular parent. For Example
Lets say PR01 is related to a three child records then the child record number should be PR01.1 the next PR01.2 and so on
Thanks in advance
i have business case where I have two objects in a masterdetail relationship. My objective is to be able to append parent record auto number field to the child record number
ie Parent record number Pr01 and child record number 1. The main thing is the child record number is a count of how many child records are associated with that particular parent. For Example
Lets say PR01 is related to a three child records then the child record number should be PR01.1 the next PR01.2 and so on
Thanks in advance
All Answers
If two objects in a master-detail relationship then create Rollup Summary field on Parent Object to COUNT child Record.
Refer this to implements Rollup summary fields:
https://trailhead.salesforce.com/en/modules/point_click_business_logic/units/roll_up_summary_fields
Write Trigger to resolve this Problem(Let's say PR01 is related to a three child record then the child record number should be PR01.1 the next PR01.2 and so on)
if you found this answer helpful then please mark it as best answer so it can help others.
Thanks
Akshay
thank you for response
@Steven Nsubuga Formula field only concatenates two fields unfortunately that does not offer a count according to the business requirements.
@Akshay_Dhiman Roll up Summary Field you can not use filter criteria to reference another field to be able to do an accurate count. unfortunately that does not work. As you know you can not use a formula field in your filter criteria.
Thanks guys for your input.
To suit your scenario, I have created 2 objects, Dad__c and DadSon__c. DadSon__c has a Master Detail field to Dad__c, the field API name is Parent__c. Dad__c's standard Name field is an Auto Number field, with Display Format as PR{00}.
I created a Text field called Number Combo (Name_Combo__c) on DadSon__c that will contain the desired name. For ease of testing, the standard Name field on DadSon__c is an Auto Number field, it is not used at all.
Next I wrote a before insert trigger, whose code is shared below, as well as a test class.
trigger
test class
Steven Nsubuga. Amazing!