Handling Approval Replacement and Flow Redirection Policy

ujjwala_678
Tera Contributor

Hi Everyone,

I’m working on an implementation involving multiple Record Producers that create Policy Exception records. Each record producer is associated with a different flow based on business requirements.

Recently, I developed a Change Approver popup. This feature allows users to replace the current approver for a policy exception. Once the new approver is selected:

  • The original approval is moved to a "No Longer Required" state.

  • A new approval is triggered for the newly selected user.

Here’s what I’m trying to achieve next:

  • If the new approval is rejected, the Policy Exception record should be moved to a "Rejected" state.

  • If the new approval is approved, the record should continue through its original associated flow (specific to the record producer used).

I’m looking for the best way to handle this logic, especially since different flows are involved. Some key questions:

  1. How can I effectively update the Policy Exception record’s state based on the new approval outcome?

  2. How can I ensure the flow continues correctly after changing the approver, without duplicating or interrupting the original flow logic?

  3. Should this be handled via Flow Designer, Scripted Flow Actions, or some other mechanism?

Any guidance, suggestions, or best practices would be greatly appreciated!

2 REPLIES 2

Udayrathore049
Tera Contributor

Change Approver Logic

In your popup backend (likely a UI Action or Script Include):

  • Cancel the current approval by updating the sysapproval_approver record to "No Longer Required".

  • Trigger a new approval for the selected user.

    • Create a new sysapproval_approver record.

    • Associate it with the same sysapproval (your Policy Exception record)



      If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

      Regards
      Uday Rathore
      ServiceNow Developer
      LinkedIn: https://www.linkedin.com/in/uday-rathore049/

_ukasz Rybicki
Giga Guru

Problem Name: Changing approver interrupts flow 🚧💥

🎯 Solution 1: Flow Designer with Subflow
General proposal: Use a dedicated subflow to handle approver changes. This subflow asks for approval, updates the u_policy_exception record state to Rejected or signals continuation, then returns control to the main flow without duplicating approval logic. 🔄😎

Detailed steps:

  1. In Flow Designer, create a subflow named Handle Approver Change.

  2. Add an Ask for Approval action targeting the sysapproval_approver table; pass u_policy_exception.sys_id.

  3. Insert an If condition:

    • If approval_state is not approved ➔ Update Record on u_policy_exception, set state = 'Rejected' .

    • ElseUpdate Record on u_policy_exception, set a boolean output flag continue_flow = true .

  4. In the main flow, replace the current approver reassignment step with a Subflow action calling Handle Approver Change, passing approval_sys_id and record_sys_id.

  5. After the subflow, use a Decision or If on continue_flow: true ➔ resume original flow branches; false ➔ end or handle rejection.

  6. Test both scenarios: rejection moves record to Rejected; approval continues original flow. 🔧🚀

Tables used: u_policy_exception, sysapproval_approver

Example: A subflow for developers/administrators in the Policy Exceptions module, automatically setting records to Rejected or resuming the configured workflow based on the new approver’s decision. 🤓🙌

🎯 Solution 2: Scripted Flow Action
General proposal: Add a simple Script action in Flow Designer that uses an if/else GlideRecord script to update the exception record’s state or set a flag for continuation, avoiding complex new methods. 💻🎉

Detailed steps:

  1. In the main flow, insert a Script action (Scripted Flow Action).

  2. Use this code (with comments):

    // Fetch approval record
    var appr = new GlideRecord('sysapproval_approver');
    appr.get(inputs.approval_sys_id);
    // Update policy exception based on approval
    var pe = new GlideRecord('u_policy_exception'); pe.get(inputs.record_sys_id);
    if (appr.state != 'approved') {
      pe.state = 'rejected'; // mark as rejected
    } else {
      inputs.continue_flow = true; // signal continuation
    }
    pe.update();
  3. Map inputs: approval_sys_id, record_sys_id; output: continue_flow.

  4. After the Script action, add an If on continue_flow: true ➔ continue main flow; false ➔ handle rejection.

  5. Test both paths. 🎯🔧

Example: A concise scripted step for a senior developer in Service Catalog, enabling flow control without extra reusable libraries. 🚀🤩

Sources:

  1. Approval re-assignment in Flow Designer, ServiceNow Community (Feb 21, 2023), discussion on handling approval reassignments in flows → https://www.servicenow.com/community/developer-forum/approval-re-assignment-in-flow-designer/m-p/248... (explains flow interruption after approver change)

  2. Flow Designer Approvals Overview, ServiceNow Community (2023), best practices for Ask for Approval and Decision Builder → https://www.servicenow.com/community/workflow-automation-articles/flow-designer-approvals-overview-w... (covers approval actions and decision routing)

Please mark as the correct answer if this helps! 😊🚀