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
netTrekker_ADnetTrekker_AD 

Workflow rule with two field updates, not updating

I am a victim of my own overthinking...

 

On Tasks, I have a VR that requires the Subject to not be left as "Call". I have another VR that requires a value be selected on a custom picklist field before the Task can be saved.

 

I have a workflow rule that is set for immediate action on any Task that fits a certain criteria. When it the rule fires, it performs two actions; a field update to put "No answer" in the subject line and a field update to update the custom picklist field with a specific value.

 

When I create a task that meets the criteria needed for the WF to work, I click save but the VRs fire before the field updates.

apex whistlerapex whistler

Not sure what your question is. VR fires before WFR as that is the execution order. A workaround is to add exception to the VR for the WFR conditions, such as

 

AND(

  condtion 1,

  NOT ( condition 2 )

)

 

It adds complexity to your VR but should work.

 

 

netTrekker_ADnetTrekker_AD

I guess I did not realize VRs fire before WFRs.

 

Thank you whistler!

apex whistlerapex whistler

No worries. Here is link to article that describes the execution order in SFDC of what happens when a record is saved.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm

 

netTrekker_ADnetTrekker_AD

One more thing if you check back on this topics, is there a way to update the Related To field other than with a trigger?

apex whistlerapex whistler

Unfortunately, WFR is not great for updating lookup fields (reference fields). If your use case is to apply the logic at point of save, then trigger and apex is the best bet to keep it seemless for the user.

 

There is another option using custom button and Javascript, but would require users to click on that button vs regular save button. For example, have a flag that is hidden from page layout, which only can be set by clicking on a custom button. Otherwise, if user tries to save without setting the flag (via out of box save button), then VR rule prevents save (this basically disables the standard save button. The custom button would also have the logic to check and update the Related To field via javascript. This concept is do-able, but adds a level of complexity.