You need to sign in to do that
Don't have an account?
GV1
Need help: field updating three level down in a trigger
I have four objects
Opportunity--->>>Lookup>>Playbook ---->>>>Master detail>>>Stage->>>>master detail>> Substage
playbook already have a few entries of stages. And each stage already has a few entries of substage value.
When we select a playbook value for Opportunity (Opportunity.Playbook__c), I need to update two other fields of Opportunity object.
First Field: out of many child (in Stage object) of the selected playbook I need to chose the Stage name of the record whose 'Sort Order' is 1; and assign that value to Opportunity.CurrentStage__c
Second field : out of many child (in SubStage object) of the above Stage I need to chose the SubStage name of the record whose 'Sort Order' is 1; and assign that value to Opportunity.CurrentSUBStage__c
I have to write a trigger to do this. Kindly help me with the code.
I have started with it as below. but not sure how to proceed further. Can someone kindly help.
if(Trigger.isUpdate && Trigger.isAfter) {
for(Opportunity opp : Trigger.new) {
if((opp.Playbook__c != null && opp.Playbook__c != Trigger.oldMap.get(opp.Id).Playbook__c)
Select id from Stage__c where Paybook__c =: Opportunity.PalayBook__c and Sort_Order__c = 1
All Answers
then u can achieve ur requirement
Three triggers are not required.
playbook already have a few entries of stages. And each stage already has a few records of substage value.
Select id from Stage__c where Paybook__c =: Opportunity.PalayBook__c and Sort_Order__c = 1
Thanks bhawani for the answer. That exactly what i guessed.
How will i select the record from Substage is more tricky for me.!!
Hi Bhawani,
I have written the following code:
I am getting this Error: Illegal assignment from LIST<Substage__c> to String
where Stage__r.Playbook__c =: Opp.Playbook__c
Apart from that,
opp.StageName = [Select id from SubStage__c where Stage__r.Playbook__c = Opp.Playbook__c and Substage_Sort_Order__c = 1];
This SOQL will return a SubStage__c object, so you will have to hold that in in same type like
SubStage__c ss = YOUR query