You need to sign in to do that
Don't have an account?
Nicholas Melonas
How to write a trigger/class between two picklist fields across objects.
Hello,
On my custom object "Project" (), I have the custom field, "Status" (MPM4_BASE__Status__c). Whenever this status is updated, I need it to instantly update to the custom "Project Status" field on the Account object (Project_Status__c). I know this can be accomplished with a formula field, but I need this trigger to happen immediately without any edits on the Account, and need the "Project Status" field to remain as a picklist field. How do I write the trigger and class for this? Thanks so much!
On my custom object "Project" (), I have the custom field, "Status" (MPM4_BASE__Status__c). Whenever this status is updated, I need it to instantly update to the custom "Project Status" field on the Account object (Project_Status__c). I know this can be accomplished with a formula field, but I need this trigger to happen immediately without any edits on the Account, and need the "Project Status" field to remain as a picklist field. How do I write the trigger and class for this? Thanks so much!
NOTE: This code has not been tested and may contain typographical or logical errors
You will obviously need to change the object and field names to match what you have in your schema.
Please try with the below trigger code : Let me know if you have any issue.
Thanks,
Abhishek
My name is Chris and I am helping Nick with these triggers...Thank you again for helping us implement these into our salesforce!! You are a huge help!
The only thing we are having problems with now is the test class. Do you have a test class that we could use to test this trigger?
Thanks,
Chris Synnott
As your original question have been answered so i would suggest you to close this question right here by marking it as Solved.
If you want a test class for your trigger than please post the related question on another forum.
That would help others to find different solutions of different questions on different forums.
Please close this question here and send me the link of new question here and i will try my level best to provide you a feasible solution as soon as possible.
In future please take care of the thing of not mixing different questions on a single forum.
Thanks,
Abhishek
Hello
In the Opportunity object, I created three record types and two custom fields:
- a picklist "Opportunity Sub-type" controlling
- a picklist "Funnel Stages" with in fact exactly the same values as the picklist standard field "StageName"
The purpose is to limit in the different record types the stages to use for each Opportunity Sub-Type.
As the field StageName is mandatory on Opportunity and not possible to define field dependencies with, I created a trigger to sync the StageName value when the same one is selected in the "Funnel_Stages__c" picklist.
------------
trigger UpdateSource on Opportunity (after update)
{
List<Opportunity> opportunitiesToUpdate = new List<Opportunity>();
for(Opportunity currOpportunity : trigger.new)
{
currOpportunity.StageName= currOpportunity.Funnel_Stages__c;
leadsToUpdate.add(currOpportunity);
}
update opportunitiesToUpdate;
}
--------------------
Not error when compiled but well when activated as I had thefollowing error message on the Opportunity page:
-------------------
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger UpdateSource caused an unexpected exception, contact your administrator: UpdateSource: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.UpdateSource: line 6, column 1
-----------------
Can somebody help me?
Thanks already.
Best regards
Jean-Luc
Please open this up as a new question on the boards. This does not related to the question here and will only confuse the issue.
I've indeed created a new one.
Rgds