Refreshing the fields based on text field(FX Rate to usd) parent to child will refresh(Calculations using formula field) parent.
Parent to child to parent updation using trigger.
Trigger:-
trigger Fieldupdations on Opportunity_Margin_Template__c (after update) {
List<Opportunity_Margin_Template__c> templist = new List<Opportunity_Margin_Template__c>();
List<Opportunity_Template_Task__c> templatetasklist = new List<Opportunity_Template_Task__c>();
set<id> setid = new set<id>();
for(Opportunity_Margin_Template__c margin: Trigger.new)
{
setid.add(margin.id);
}
List<Opportunity_Margin_Template__c> tasklist = [select Id,Name,Template_Save_as__c,FX_Rate_to_USD__c from Opportunity_Margin_Template__c
where id in:setid];
templatetasklist =[select id, Cost_Hr__c,Opportunity_Margin_Template__c from Opportunity_Template_Task__c where Opportunity_Margin_Template__r.id In : setid];
for(Opportunity_Margin_Template__c temp: tasklist)
{
if(temp.FX_Rate_to_USD__c!=Trigger.oldmap.get(temp.Id).FX_Rate_to_USD__c)
{
templist.add(temp);
}
}
update templatetasklist ;
update templist;
}
Parent to child to parent updation using trigger.
Trigger:-
trigger Fieldupdations on Opportunity_Margin_Template__c (after update) {
List<Opportunity_Margin_Template__c> templist = new List<Opportunity_Margin_Template__c>();
List<Opportunity_Template_Task__c> templatetasklist = new List<Opportunity_Template_Task__c>();
set<id> setid = new set<id>();
for(Opportunity_Margin_Template__c margin: Trigger.new)
{
setid.add(margin.id);
}
List<Opportunity_Margin_Template__c> tasklist = [select Id,Name,Template_Save_as__c,FX_Rate_to_USD__c from Opportunity_Margin_Template__c
where id in:setid];
templatetasklist =[select id, Cost_Hr__c,Opportunity_Margin_Template__c from Opportunity_Template_Task__c where Opportunity_Margin_Template__r.id In : setid];
for(Opportunity_Margin_Template__c temp: tasklist)
{
if(temp.FX_Rate_to_USD__c!=Trigger.oldmap.get(temp.Id).FX_Rate_to_USD__c)
{
templist.add(temp);
}
}
update templatetasklist ;
update templist;
}
No comments:
Post a Comment