In the following trigger, it gets child records of a custom object based on the contact id of a record that was just saved. I need to update their data into a field on the parent contact record.
The field on the contact record is named Related_Staff_Positions__c and it is a long text field.
I.e. if 3 child records were returned, I need to clear the Related_Staff_Positions__c field, and then add each record on a separate line in the Related_Staff_Positions__c field such that line 1 shows first name, last name role line 2 same thing line 3 same etc.
What do I add in the second for loop below?
trigger trgr_Related_Staff_Position on Related_Staff_Positions__c (after insert,after update,after delete)
{
List<String> contactIds = new List<String>();
List<Related_Staff_Positions__c> rsp_List = new List<Related_Staff_Positions__c>();
rsp_List = [Select Contact__c , first_name__c, last_name__c from Related_Staff_Positions__c where Id IN: Trigger.New];
for(Related_Staff_Positions__c rsp : rsp_List){
contactIds.add(rsp.Contact__c);
}
List<Related_Staff_Positions__c> otherChildren = [Select Contact__c , first_name__c, last_name__c from Related_Staff_Positions__c where Id IN: contactIds];
for(Related_Staff_Positions__c rsp : otherChildren){
}
}