Siddhesh Gawade
Mega Sage
Mega Sage

What goes wrong

When a catalog request creates an RITM, we may have a Flow, or integration that calls external systems and update RITM variables some seconds later. If a fulfiller opens the RITM before the Flow finishes and saves the form, the empty values shown in the UI can be written back to the record and overwrite the Flow’s results.

 

A real-world scenario

Alice requests software. A Flow calls the 3rd party application and will set "serial_number" and "vendor" on the RITM after receiving the vendor response.

 

A fulfiller opens the RITM immediately, sees blank serial_number, edits something small, and clicks Save. That save writes the blank field back and either conflicts with or erases the values the Flow later writes.

 

Why this happens: UI vs backend timing

Regular table fields in ServiceNow often get near‑real‑time updates, but catalog variables do not. The UI displays the current form state (which can be stale for variables) while the backend processing continues. A user-initiated save between backend updates can overwrite later backend writes.

 

Solution Overview
Add a read-only RITM variable, for example "verification_stage", that the Flow updates to reflect progress (e.g., Running → Waiting for Input → Completed).

 

Add an onLoad client script on the RITM form that, while verification_stage is not Completed, shows a loading indicator and prevents/defers saves by reloading or locking the form until the stage becomes Completed.

 

Implementation Details: What to create

verification_stage variable: Make it read-only.
Use distinct values for stages that need human intervention (so you can avoid forcing reloads during manual steps).


Flow updates: Set stage at job start, at pause points (where human input is required), and to Completed only after all backend writes finish and commit.


Client script scope:
Only run on the RITM form (not on Service Portal) unless adapted for portal use.

 

Client Script (onLoad)

function onLoad() {

var stage = g_form.getValue('verification_stage');
if (stage != "input_required" || stage != "completed") { // Checking flow/backend executions
var loadingDialog = new GlideDialogWindow("dialog_loading", true);
loadingDialog.setPreference('table', 'loading');
loadingDialog.setTitle('Loading...');
loadingDialog.render();

var setTimer = setTimeout(setTimerDelay, 2000);
}
}

function setTimerDelay() {
location.reload();
}

SiddheshGawade_0-1766475771425.pngSiddheshGawade_1-1766475775986.png

 

The script shows a loading dialog and reloads every 2 seconds (this can vary or can be changed) until the Flow sets the stage to Completed or human intervention required.

 

Avoiding pitfalls

Use explicit stage values for manual steps: if the Flow needs user input or approvals, set a “Waiting for Input” stage so the client script does not auto-reload and interrupt the user. Alo it is recommended to limit the script to unintended catalog items/views.

 

Summary

Problem: Backend Flows/integrations populate RITM variables after creation, and users saving the form early/during execution before reloading can overwrite those values.

 

Fix: Use a read-only verification_stage variable that the Flow updates and an onLoad client script to reload/lock the RITM until the Flow completes.

 

I’m sharing this as an early solution — please comment with improvements and suggestion if you have any😊

Version history
Last update:
yesterday
Updated by:
Contributors