How to avoid duplicate offboarding request for same user

Aswathy3
Tera Expert

Hi All,

In our ServiceNow instance, offboarding requests are getting generated based on the alert from an external application.

Also, sometimes managers are raising manual offboarding requests due to this duplicate offboarding requests are getting generated for same user.

Is there a way to avoid this duplicate tickets in both scenarios,

1) Before generating auto ticket, is there a way to check offboarding request is already available or not.

2) Before manual submission of ticket by manager, is there a way to check offboarding request is available or not.

In offboarding requests, we are using "Departing User field and Departing Date custom fields for identifying the users.

Can anyone please help me on this?

Thank in advance.

 

Regards

Aswathy

2 REPLIES 2

Prathmeshdagade
Mega Guru

Hello @Aswathy3 

Prevent duplicate auto-generated offboarding requests (from external alerts)

         Step 1 – Look Up Existing Record
Before creating a new offboarding request, perform a lookup using:

  • Catalog Item = Offboarding

  • Departing User

  • Departing Date

  • Requested For (if applicable)

This can be done by:

  • Checking the Request / RITM table

  • Or maintaining a custom Idempotency table (preferred for integrations)

           Step 2 – Decision

  • If record exists (Status = Success):

    • Do not create a new ticket

    • Optionally update the existing request or log the event

  • If no record found:

    • Proceed to create the offboarding request

    • Create an Idempotency Record so future alerts won’t create duplicates

      Before Insert Business Rule (Backend enforcement)

      Create a Before Insert Business Rule on:

      • sc_req_item (or your offboarding table)

      Logic:

      • Query for existing active offboarding requests using:

        • Departing User

        • Departing Date

      • If found:

        • Abort insert

        • Add an error message

          If this response proves useful, please mark it as Accept as Solution and Helpful. Doing so benefits both the community and me. 👍🙂

SagnicDas_dev
Mega Guru

Hi @Aswathy3 ,

Please try the solution below may be it will help you ...

To prevent duplicate offboarding requests in Servicenow for both automated and manual scenarios, you can implement a combination of server-side validation for integrations and client-side validation for the manual form.
 
1. Automation: Before Generating Auto-Tickets
When receiving an alert from an external application (e.g., via IntegrationHub or a Scripted REST API), you should perform a lookup before the record is inserted.
  • Logic: Query the offboarding table to see if an active request already exists for that user and departure date.
  • Implementation:
    • Flow Designer: Use the Look Up Record action before any "Create Record" action. Set conditions where Departing User is the same and State is not 'Closed' or 'Cancelled'. Use an If condition: only proceed with creation if the lookup finds no record.
    • Scripted Integration: If using a script, use GlideRecord to query the table. If gr.next() returns true, skip the insert and instead log a message or update the existing ticket.
  • Database Level (Optional): Create a Unique Database Index on the combination of Departing User and Departing Date to provide a hard stop against duplicates at the database level. 
 
2. Manual: Before Submission by Manager
For manual requests through the Service Catalog, you need to provide real-time feedback to the manager to prevent them from submitting the form.
  • Logic: Use an onSubmit Catalog Client Script that performs an asynchronous check via GlideAjax.
  • Implementation Steps:
    1. Script Include: Create a client-callable Script Include (e.g., OffboardingCheckUtils) with a function that queries the offboarding table using the sysparm parameters for the user and date.
    2. Catalog Client Script (onSubmit):
      • Trigger the GlideAjax call when the manager clicks submit.
      • If a duplicate is found, use g_form.addErrorMessage() to inform the manager and return false to halt the submission.
    3. Proactive Check (onChange): For a better user experience, run a similar check when the Departing User field changes. This warns the manager immediately before they even finish the form. 

      If you find this useful please mark it as helpful...

      Regards,

      Sagnic