You need to sign in to do that
Don't have an account?
Sainath Venkat
class to update parent id in grand child
I am working on one trigger which will populate the Project id in Project Roles.
I have SOW__c object which is having self lookup relationship, Project__c object is having look up to sow object and Project_Role__c object is having look up to sow.
since SOW is having self look up, I will be having parent sow and child sow records, if I create any role to child sow then I want to populate project id that is related to parent sow to the role that is creating to child sow, I tried below a class but somehow it's not working.
Can anyone help me out with this issue, please?
I have SOW__c object which is having self lookup relationship, Project__c object is having look up to sow object and Project_Role__c object is having look up to sow.
since SOW is having self look up, I will be having parent sow and child sow records, if I create any role to child sow then I want to populate project id that is related to parent sow to the role that is creating to child sow, I tried below a class but somehow it's not working.
Can anyone help me out with this issue, please?
public static void CRroleProjectUpdate(List<Project_Role__c> projectroles){ set<Id> CRsowId = new set<Id>(); Map<Id,List<Project__c>> CRProjectMap = new Map<Id,List<Project__c>>(); for(Project_Role__c proles : projectroles){ CRsowId.add(proles.SOW__r.Related_SOW__c); system.debug('CRsowId is ' + CRsowId); } if(!CRsowId.isEmpty()){ for(Project__c project:[select Id, SOW__c from Project__c where SOW__c IN: CRsowId]){ list<Project__c> CRProjectList= CRProjectMap.containsKey(project.Sow__c)?CRProjectMap.get(project.Sow__c):new list<Project__c>(); CRProjectList.add(Project); CRProjectMap.put(project.SOW__c, CRProjectList); } for(Project_Role__c proles : projectroles){ if(CRProjectMap.ContainsKey(proles.SOW__r.Related_SOW__c)){ for(Project__c p : CRProjectMap.get(proles.SOW__r.Related_SOW__c)){ proles.Project__c = p.Id; } } } } }
I have found below link that has a similar requirement can you try checking it out:
>> https://developer.salesforce.com/forums/?id=906F0000000BXIFIA4
I hope this helps.
Regards,
Anutej
I was reading your contents and found a lot of information. Keep posting such contents for us. SEO Dubai (https://www.dubaifirstseo.com/)