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
Bryan Leaman 6Bryan Leaman 6 

Determine newly-pending approval step during approval

We have some approval processes that control the flow of a document through a series of stages. To accomplish this we have field updates upon approval & rejection to set the new stage.

A challange with this approach is how to handle optional approval steps. For example, if a product sale requires customization, it enters a "Production" step and we want the document to reflect a status of "In Production". But if there's nothing to do it can move automatically to a "Delivery" step.   However, I cannot find a way to determine during the triggerd field update that the Production approval step is being skipped due to conditional logic in the approval process.  

I *have* found a way to see the currently pending approval step name, but during approval it still shows the step being approved, not the next applicable step. So after approval, if a step was skipped, any *new* update to the record would reveal it's at the Delivery step instead of "Production," but I cannot find a way to determine this at the time the prior step is being approved. So what we've had to do is duplicate the logic in code that we have in the approval process so our trigger can determine if the next step is being skipped or not. Very clunky!

Does anybody have a better way? It'd be great if we could just designate that skipped steps also update fields, or if approval processes could perform field updates upon entry to a step instead of just approval or rejection of a step.

Any thoughts?
VinayVinay (Salesforce Developers) 
Hi Bryan,

This seem to be trickly,  try using any new field and update condition in such a way your trigger or approval process doesn't run at same time and skip the other component.

Bryan Leaman 6Bryan Leaman 6
I guess I could always re-update the record in an @future method any time the status changes (indicating an approval step was completed). That update would then see the current approval step and could update the status again, if needed. But I don't like that option. We already have too many dml triggered updates. Thanks.