You need to sign in to do that
Don't have an account?
Nirmal9114
Trigger to copy opportunity related list field when opportunity status is "Launched"
My requirement is to update the related list "FGM_Portal__Grantee_Budget_Line_Item__c " Field value from one field to other Only when when opportunity status is LAUNCHED
Please help me in code. i am missing out something.
This is only the class.
APEX CLASS :
public class UpdateOriginalBudget{
List<Id> oppIdlist = [Select id from opportunity where StageName = 'Launched'];
//opplist = [Select id, Name, StageName from opportunity where StageName = 'Launched'];
List<FGM_Portal__Grantee_Budget_Line_Item__c> GbList = [Select Id,Original_Budget__c,FGM_Portal__Amount__c,FGM_Portal__Opportunity__c from FGM_Portal__Grantee_Budget_Line_Item__c where FGM_Portal__Opportunity__c IN : oppIdlist ] ;
//GbList = [Select Id,Original_Budget__c,FGM_Portal__Amount__c,FGM_Portal__Opportunity__c from FGM_Portal__Grantee_Budget_Line_Item__c where FGM_Portal__Opportunity__c : oppList[0].Name ] ;
public void UpdateOriginalBudgetMethod(){
if(GbList.size>0)
{
for(FGM_Portal__Grantee_Budget_Line_Item__c gb : GbList ){
gb.Original_Budget__c= gb.FGM_Portal__Amount__c ;
}
}
}
}
Please help me in code. i am missing out something.
This is only the class.
APEX CLASS :
public class UpdateOriginalBudget{
List<Id> oppIdlist = [Select id from opportunity where StageName = 'Launched'];
//opplist = [Select id, Name, StageName from opportunity where StageName = 'Launched'];
List<FGM_Portal__Grantee_Budget_Line_Item__c> GbList = [Select Id,Original_Budget__c,FGM_Portal__Amount__c,FGM_Portal__Opportunity__c from FGM_Portal__Grantee_Budget_Line_Item__c where FGM_Portal__Opportunity__c IN : oppIdlist ] ;
//GbList = [Select Id,Original_Budget__c,FGM_Portal__Amount__c,FGM_Portal__Opportunity__c from FGM_Portal__Grantee_Budget_Line_Item__c where FGM_Portal__Opportunity__c : oppList[0].Name ] ;
public void UpdateOriginalBudgetMethod(){
if(GbList.size>0)
{
for(FGM_Portal__Grantee_Budget_Line_Item__c gb : GbList ){
gb.Original_Budget__c= gb.FGM_Portal__Amount__c ;
}
}
}
}
- Add the entry criteria for your process builder as Opportunity status equals Launched
- In the immediate actions, click Add action and select action type as update record. Then choose the object and fields which you want to update
- Then activate the process builder
For more details about process builder, check this trailhead module - https://developer.salesforce.com/trailhead/business_process_automation/process_builderBut the field from which i have to copy the value is in the same object.
eg as i have to copy Amount value to Original_budget value which are on same related list object.
I tried using by Process builder. In field to update i am getting opportunity fields on which my Process builder is.