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
MikeyJamJamsMikeyJamJams 

Unable to get PRIORVALUE() Field Update to Work Upon Approval Rejection

Hello, We have an approval process in place so that when a user updates an Account Shipping Address, the user submits an approval request, and if these changes are rejected, they are to revert back to the previous value.

 

I've set up our approval process so that whenever an approval request gets rejected, five field updates are kicked off, using the following formulas

PRIORVALUE(ShippingStreet)

PRIORVALUE(ShippingCity)

PRIORVALUE(ShippingState)

PRIORVALUE(ShippingPostalCode)

PRIORVALUE(ShippingCountry)

 

However, whenever I test out our process by changing one of these values, submitting a request for approval and then rejecting it, none of the fields revert back to their original value. I'm not sure what I'm doing wrong if someone could help provide some insight.

 

Thanks,

Mike

 

matermortsmatermorts

I don't think PRIORVALUE will work for your scenario, since Salesforce doesn't store the prior value after immediate workflow actions have taken place, although I can't find any documentation to suppor this theory.

 

I think what you want to do instead, is have a workflow fire, any time the address is edited. This workflow could take your old values, via the PRIORVALUE argument, and populate new custom fields with these old values. Later, if the change is rejected, you can have several new field updates fire simultaneously (one for each address field needing to be udpated) that will take your address info from the custom fields, and populate the values back into the original fields.

 

Does that make sense and does it seem like it'll work? I haven't tried it; just thought it's worth looking into.

MikeyJamJamsMikeyJamJams

Here's the thing. Our approval process is actually kicked off by a trigger if the address information is updated. I've created a workflow rule to run every time a record is edited or created, and to store the previous Street Address into a custom field. However, whenever I edit the record and hit save, I get the following error:

 

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger Updated_Customer_Approval_Process caused an unexpected exception, contact your administrator: Updated_Customer_Approval_Process: execution of AfterUpdate caused by: System.DmlException: Process failed. First exception on row 0; first error: ALREADY_IN_PROCESS, Cannot submit object already in process.: []: Trigger.Updated_Customer_Approval_Process: line 19, column 1".

 

I'm guessing this is because the workflow rule and approval role are trying to run at the same time?