You need to sign in to do that
Don't have an account?
Developer99
Update Child Field once Parent Field is Updated
have 2 objects name quote,quotelineitems here both are related with master-detail relationship, i wrote a trigger on quote(parent). whenever any field is changed in quote automatically in quoteline item i have a field Isupdated change to false.Intinally while inserting records Isupdate field is True, whenever i update any field in quote then it have to change to false, i am getting the issuse while inserting records automatically Isupdated field is taking false, without updating anything in quote. My trigger:
trigger quotetrg on Quote__c (after update)
{
list<Quote__c> s1 = new list<Quote__c>();
s1 = [select City__c from Quote__c];
list<Quote_Item__c> f1 = new list<Quote_Item__c>();
f1 = [select Updated_del__c from Quote_Item__c];
for(Quote_Item__c f :f1)
{
for(Quote__c s : Trigger.old)
{
f.Updated_del__c = s.City__c;
f.Updated_del__c = 'Krish';
update f;
}
}
}
trigger quotetrg on Quote__c (after update)
{
list<Quote__c> s1 = new list<Quote__c>();
s1 = [select City__c from Quote__c];
list<Quote_Item__c> f1 = new list<Quote_Item__c>();
f1 = [select Updated_del__c from Quote_Item__c];
for(Quote_Item__c f :f1)
{
for(Quote__c s : Trigger.old)
{
f.Updated_del__c = s.City__c;
f.Updated_del__c = 'Krish';
update f;
}
}
}
there is workflow rule is there on Quote_item_c which will fire when i edit the records in Quote_item_c.
that means shall i remove that W.F on child object shall i write the trigger..??
As per my requriment i want to know when ever any changes in the Quot_item_c fields so that's why i created the workflow, is there any other way when ever i change any field in the Quote_item_c i want to change the Update__c which is in Quote_-iteM__c
2. Set the Update__c on Quote_item__c to True/False when there is any change on the same object (Quote_Item__c.)
The first condition will be met by the trigger you wrote on Quote__c.
However, regarding the workaround on Quote_item__c, even if you write a separate trigger on quote_item__c, if the changes on any of the fields on quote_item__c are effecting parent object fields(Quote__c fields) it will execute parent triggers as well. Review the order of execution at the link below for more information
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm