function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Manju_BNManju_BN 

Field Update

Hi All,

 

I am adding a custom picklist field in case object, which has the values "YES" and "NO". My requirement is when ever the field is changed to "YES" then the change date should be displayed to next to that..... Do I have to write the trigger for this?

Best Answer chosen by Admin (Salesforce Developers) 
Jake GmerekJake Gmerek

Sorry I forgot about that, use:

 

AND(ISPICKVAL(Governance_Approval__c ,"YES"), ISCHANGED(Governance_Approval__c))

All Answers

Jake GmerekJake Gmerek

You should not have to write a trigger.  From what you describe, a workflow rule with a field update should suffice.

Manju_BNManju_BN

Hi Jake..

 

Actually mine is a different scenario...

1.There is a picklist field Governance with values 1, 2, 3

2.whenever we select 1 or 2 in Governance, there is another pick list called Governance approval with values YES & NO... That field should be populated YES

3.When Governance approval is changed to YES, then that yes changed date should be displayed....

 

In this situation what i have to do?

Jake GmerekJake Gmerek

Is this on a standard page or a custom VF page?  I assumed that you wanted to capture the changed date in the DB and not just display it for the duration of the page view, is this correct?

 

So assuming that this is on a standard page here are the steps:

 

1.  Create the last updated field (or approval date, or whatever you want to call it) and put it on the page where you want it.

2.  Create a new workflow rule, use the "created, and any time it’s edited to subsequently meet criteria" option.

3.  Select "Formula Evaluates to True"

4.  Your formula will be something like AND(Governance_Approval__c = "YES", ISCHANGED(Governance_Approval__c))

5.  Create the field update to update the field that you created above with the current date.

 

Let me know if you have any questions.

Manju_BNManju_BN

I am getting the following error, while following your steps

 

Field Governance_Approval__c is a picklist field. Picklist fields are only supported in certain functions

Jake GmerekJake Gmerek

Sorry I forgot about that, use:

 

AND(ISPICKVAL(Governance_Approval__c ,"YES"), ISCHANGED(Governance_Approval__c))

This was selected as the best answer
Manju_BNManju_BN

Thanks Jake,

 

In the next condition,

 

1.When ever Approval Process changes to Yes, then one more picklist Review Outcome with Values (Approved, Rejected, Pending and Overdue) should be changed to "Pending"

2.Similar to the previous again here date should be populated

3.It should remain in "Pending" untill it is decesioned by approval team.

4.If "Review outcome" is in "Pending" for more than 30 days from date it is changed, then automatically its value should be changed to "OVERDUE"

Jake GmerekJake Gmerek

So you would do a similar process based around the Review Outcome picklist, but in addition to the field update, you need to do a timed workflow update (you can do both in the same overall workflow).

 

The field update will update the changed field and the timed portion will fire off thirty days after that date.  Note: it will check the rules again before the timed portion fires, so if the pick list is changed off of pending before the thirty day timeframe the workflow will not update the field.

Manju_BNManju_BN

Thanks a lot Jake.................

:) 

 

Manju_BNManju_BN

Jake,

 

Here the dates are not populating while creating a new record.............

Jake GmerekJake Gmerek

Yep, cause isChanged is false since it is a new record.

I did not realize that that was a requirement.

 

Try this:

AND(ISPICKVAL(Governance_Approval__c ,"YES"), OR(ISCHANGED(Governance_Approval__c),ISNew(Governance_Approval__c)))

 

 

Manju_BNManju_BN

I think ISNEW() function wont work for picklist fields, so I m getting the error as

 

Field Governance_Approval__c is a picklist field. Picklist fields are only supported in certain functions

Jake GmerekJake Gmerek

Sorry I wrote that too fast and did not double check, it should be:

 

AND(ISPICKVAL(Governance_Approval__c ,"YES"), OR(ISCHANGED(Governance_Approval__c),ISNew()))

 

It's the whole record that is new, not just one field.

Manju_BNManju_BN

Thanks Jake..

 

Now its working fine........

Jake GmerekJake Gmerek

Your Welcome!  Happy to help!