function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Karunat1Karunat1 

I have a scenario, Can anyone help me on this?

When I mark a resume__c as Active(picklist value).
All the applications for this candidate should be updated with the current resume(Current is picklist  value on Application__c)
(Exsiting records should also be updated if above scenario will be match)
Parent--- Resume
Child--- Application
Resume__c and Application__c are Child of Candidate__c
 
Best Answer chosen by Karunat1
Waqar Hussain SFWaqar Hussain SF
Hi Karuna, 

I assume you have picklist field Resume__c on Resume__c  custom object. And Resume__c and Application__c are Child of Candidate__c.
assuming Candidate__c is the lookup field on resume object to Candidate object.
 
Trigger ResumeTrigger on Resume__c (after update){
    set<Id> CandidateIds = new set<Id>();
    
    for(Resume__c res : trigger.new){
        if(trigger.oldMap.get(res.Id).Resume__c != res.Resume__c && res.Resume__c == 'Active'){
            CandidateIds.add(res.Candidate__c);
        }
    }
    
    if(CandidateIds.size() > 0){
        list<Candidate__c> candidates = [Select Id, Current__c from Application__c where Candidate__c IN : CandidateIds];
        for(Candidate__c cand : candidates){
            Cand.Current__c = 'current resume';
        }
        update candidates;
    }
}

Let me know If you have any concern.
 

All Answers

Waqar Hussain SFWaqar Hussain SF
You can develop a trigger on resume Object, So when a resume is updated to Active, the trigger will fire and will get the candidate ID from the resume and using this candidate Id you will have to get its all applications. Then update the application record with current resume.
Waqar Hussain SFWaqar Hussain SF
Hi Karuna, 

I assume you have picklist field Resume__c on Resume__c  custom object. And Resume__c and Application__c are Child of Candidate__c.
assuming Candidate__c is the lookup field on resume object to Candidate object.
 
Trigger ResumeTrigger on Resume__c (after update){
    set<Id> CandidateIds = new set<Id>();
    
    for(Resume__c res : trigger.new){
        if(trigger.oldMap.get(res.Id).Resume__c != res.Resume__c && res.Resume__c == 'Active'){
            CandidateIds.add(res.Candidate__c);
        }
    }
    
    if(CandidateIds.size() > 0){
        list<Candidate__c> candidates = [Select Id, Current__c from Application__c where Candidate__c IN : CandidateIds];
        for(Candidate__c cand : candidates){
            Cand.Current__c = 'current resume';
        }
        update candidates;
    }
}

Let me know If you have any concern.
 
This was selected as the best answer
Karunat1Karunat1
Thank You!! Hussain. It's working..