You need to sign in to do that
Don't have an account?
Krishna Sahu 1
I want to update parent account object picklist field when child education field is update as completed
public static void updateJourneyStatus(Map<Id,Education_Request__c> newMap, Map<Id,Education_Request__c> oldMap){
Map < Id, Education_Request__c > mapAccount = new Map < Id, Education_Request__c >();
List < Account > listAccount = new List< Account >();
for ( Education_Request__c acct : newMap.values() ) {
if (acct.education_status__c != oldMap.get( acct.Id ).education_status__c && acct.education_status__c=='Completed'){
mapAccount.put( acct.Id, acct );
}
if ( !mapAccount.isEmpty() ) {
for ( Education_Request__c edRequest : mapAccount.values() ) {
if(edRequest.education_status__c=='Completed'){
Account acc=new Account();
acc.Name=edRequest.Id;
acc.journey_stage__c='Psych Evaluation';
listAccount.add(acc);
}
}
update listAccount;
}
}
}
Map < Id, Education_Request__c > mapAccount = new Map < Id, Education_Request__c >();
List < Account > listAccount = new List< Account >();
for ( Education_Request__c acct : newMap.values() ) {
if (acct.education_status__c != oldMap.get( acct.Id ).education_status__c && acct.education_status__c=='Completed'){
mapAccount.put( acct.Id, acct );
}
if ( !mapAccount.isEmpty() ) {
for ( Education_Request__c edRequest : mapAccount.values() ) {
if(edRequest.education_status__c=='Completed'){
Account acc=new Account();
acc.Name=edRequest.Id;
acc.journey_stage__c='Psych Evaluation';
listAccount.add(acc);
}
}
update listAccount;
}
}
}
You can use the below Class for the same. I hope you are using after Update context for the trigger
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
Can you confirm if Account is the Parent object to the Education Request object. Can you confirm the Name of the Account field on the Education Request object so I can try the logic for the same.
Thanks,
You can use the below Class for the same. I hope you are using after Update context for the trigger
If this solution helps, Please mark it as best answer.
Thanks,
yes account is parent object and education is child object.
On account object journey stage is field which i want to update when child object education status field updated as completed.
Can you try the above code which I have shared. Replace Account__c with the API name of Account field on the Education_Request__c object.
Thanks,
Thank you for the code it is working.
Thank you