You need to sign in to do that
Don't have an account?
V1nit
Cross Object Trigger to update a field
I am fairly new to apex.
I have two custom objects Obj1__c and Obj2__c. These two are related objects.
I have a field Status__c on Obj1__c which is a picklist with 5 values and I also have a field Status__c on Obj2__c which is a picklist again with 5 values.
Now, my question is, When the Status__c on Obj1__c is set to value4 or value5 then, I need to change the value of Status__c on Obj2 to value4 or value5 respectively. How can I do that using triggers? Any ideas?
try this one
Thanks,
B
All Answers
Hi,
you need to build trigger when you are trying to update fields from related object.
If you come up with API name of object and fields of objects , We can help you to build trigger code.
Thanks
Bala
Hi,
Thanks for the reply.
Opportunity__c is my main object and Resource_Request__c is a related list under the Opportunity__c object.
If I change the status on Opportunity__c to value4 or value5 then the status on the related Resource_Request__c record should change to the same value4 or value5
API names of Objects:
Opportunity__c
Resource_Request__c
API names of picklist fields:
Status__c (on Opportunity__c)
Status__c (on Resource_Request__c)
Does your Opportunity__c contains more than one Resource_Request__c records,
In that case you want to change status of all records ?
Thanks,
Yes, it might have multiple Resource_Request__c..... I want to change the Status on all the Related Resource_Request__c records.
Thanks,
V1nIt
what is API name of the relation ship field (Lookup to opportunity__c) on Resource_Request__c object ?
Thanks,
The api name of the field is Opportunity__c
thanks for details
try this code
Hope this will help you ,
If you need any more help , let us know
Thanks,
B
Works fantastic . Thanks for that. But I need the Status__c on Resource_Request__c to be changed only if the Status__c on Opportunity__c is changed to the values "On Hold" or "Withdrawn".
try this one
Thanks,
B
Great Thanks,
You saved my day.
Working Perfect !
To deploy this into production, do I need to have a test class ? If so what should be in the test class ?
Hi B,
Can you please help me on the following functionality:
When the Lead is conerted,I want the status of the Task to automatically change to "Completed"
Kindly please help me with the trigger for this functionality.
Thankinh you in advance.
Regards
Lucy