You need to sign in to do that
Don't have an account?
Poorna Developer
Apex Trigger to track the Picklist value.
Hi Everyone,
I have a object named 'Application__c' and Picklist field named 'Stage__c'['Red', 'Blue','Pink','Black']
Whenever the 'Stage__c' picklist value is changed I need to track that field value.
ie. When picklist value changed from Red -> Blue I need to track this field in my trigger. Is this possible?
Any help.
Thankyou all.
I have a object named 'Application__c' and Picklist field named 'Stage__c'['Red', 'Blue','Pink','Black']
Whenever the 'Stage__c' picklist value is changed I need to track that field value.
ie. When picklist value changed from Red -> Blue I need to track this field in my trigger. Is this possible?
Any help.
Thankyou all.
You can try this approch to solve your problem. Trigger.new : Returns a list of the new versions of the sObject records. Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.
Trigger.old : Returns a list of the old versions of the sObject records. Note that this sObject list is only available in update and delete triggers.
If you find your Solution than mark as this as a best answer.
Thanks and Regards
Suraj Tripathi.
All Answers
You can try this approch to solve your problem. Trigger.new : Returns a list of the new versions of the sObject records. Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.
Trigger.old : Returns a list of the old versions of the sObject records. Note that this sObject list is only available in update and delete triggers.
If you find your Solution than mark as this as a best answer.
Thanks and Regards
Suraj Tripathi.
Its always better to use configuration stuff instead of code, if its really not necessary to perform any additional logic.
To do it via configuration:
1. Create a Workflow Rule on Application__c object
2. Set Evaluation Criteria to "Every time a record is created or edited"
2. Change Rule Criteria to "formula evaluates to true"
3. Enter the following formula:
ISCHANGED ( Application__c.Stage__c )
4. Under Immediate Workflow Actions, you can define to perform any of the available actions such as Email Alert, Field Update, Outbound message, create a task.
To do it via Trigger to track changes to the picklist field:
While using triggers,you can make use of before insert,before update context or Trigger Context Variables.
Reference:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm
Hope above information helps, Please mark as Best Answer so that it can help others in the future.
Thanks.