Remove State from Change Request Flow from Service Operations Workspace

ponranjitha
Tera Contributor

Hi,

 

 

We would like to remove custom states from the Change Request form in Service Operations Workspace. However, we cannot deactivate these state choices as it would impact existing change records. We attempted to modify the Data Broker server script “Change Model States” by adding a condition to exclude those choices, but it did not work. Could you please assist us with this?

 

ponranjitha_1-1779100627078.png

 

1 ACCEPTED SOLUTION

Hi @ponranjitha 

From your screenshot, the Stepper component in UI Builder is not hard‑coded—its Items property is bound to:

Items → stepperData > steps

So you cannot remove steps directly on the Stepper UI.
You must remove/filter the unwanted items from the data array (stepperData.steps) that feeds the stepper.

Below are the best ways to do it (choose based on how your steps are coming).

1) Remove steps by filtering the data (Most common / recommended)
Where to do it
Go to Data and scripts (left bottom panel) → find the data resource / client script that builds stepperData.

Usually it is one of these:

a Client Script that sets stepperData.steps
a Transform / Map script for the data resource
a Scripted data resource returning the steps
What to do
Filter out steps you don’t want (example: remove Review and Canceled).

Example (Client Script / Transform Script)


// stepperData.steps = [{ id: 'new', label: 'New' }, ...]

 

// Remove specific steps by id (recommended)

const removeIds = ['review', 'canceled'];

 

stepperData.steps = (stepperData.steps || []).filter(s => !removeIds.includes(s.id));

 

This will immediately remove those choices from the stepper because the Stepper only renders what exists in steps.

2) Remove steps based on the record’s state model (If steps come from Change state flow)
In Change/Workspace implementations, steps are often generated from state values (e.g., new, assess, authorize, scheduled, implement, review, closed, canceled).

So you can filter using value / state instead of id.

 

const removeStates = ['review', 'canceled'];

 

stepperData.steps = (stepperData.steps || []).filter(s => !removeStates.includes(s.value));

 

Tip: check what your step objects look like (id/value/label) by logging them in a client script.

3) Don’t delete steps — hide them conditionally (Role / condition based)
If you want steps visible only for certain users/roles or conditions:

 

const isAdmin = (gs.getUser().hasRole('admin')); // server side only

// In UI Builder client side you typically use user roles from session/user profile data.

 

stepperData.steps = (stepperData.steps || []).filter(step => {

  if (!isAdmin && step.id === 'canceled') return false;

  return true;

});

 

 

View solution in original post

5 REPLIES 5

Venky Kshatriy2
Mega Sage

Hi @ponranjitha  Go to UI Builder open the service operations workspace open the record page and click the edit content after open the change over view then update the stepper

VenkyKshatriy2_0-1779101753554.pngVenkyKshatriy2_1-1779101777205.pngVenkyKshatriy2_2-1779101797142.png

 

Hi Venky,

We are not able to edit. Please see below screenshot and help us on how to update and where to update.

 

ponranjitha_0-1779102698045.png

 

Hi @ponranjitha 

From your screenshot, the Stepper component in UI Builder is not hard‑coded—its Items property is bound to:

Items → stepperData > steps

So you cannot remove steps directly on the Stepper UI.
You must remove/filter the unwanted items from the data array (stepperData.steps) that feeds the stepper.

Below are the best ways to do it (choose based on how your steps are coming).

1) Remove steps by filtering the data (Most common / recommended)
Where to do it
Go to Data and scripts (left bottom panel) → find the data resource / client script that builds stepperData.

Usually it is one of these:

a Client Script that sets stepperData.steps
a Transform / Map script for the data resource
a Scripted data resource returning the steps
What to do
Filter out steps you don’t want (example: remove Review and Canceled).

Example (Client Script / Transform Script)


// stepperData.steps = [{ id: 'new', label: 'New' }, ...]

 

// Remove specific steps by id (recommended)

const removeIds = ['review', 'canceled'];

 

stepperData.steps = (stepperData.steps || []).filter(s => !removeIds.includes(s.id));

 

This will immediately remove those choices from the stepper because the Stepper only renders what exists in steps.

2) Remove steps based on the record’s state model (If steps come from Change state flow)
In Change/Workspace implementations, steps are often generated from state values (e.g., new, assess, authorize, scheduled, implement, review, closed, canceled).

So you can filter using value / state instead of id.

 

const removeStates = ['review', 'canceled'];

 

stepperData.steps = (stepperData.steps || []).filter(s => !removeStates.includes(s.value));

 

Tip: check what your step objects look like (id/value/label) by logging them in a client script.

3) Don’t delete steps — hide them conditionally (Role / condition based)
If you want steps visible only for certain users/roles or conditions:

 

const isAdmin = (gs.getUser().hasRole('admin')); // server side only

// In UI Builder client side you typically use user roles from session/user profile data.

 

stepperData.steps = (stepperData.steps || []).filter(step => {

  if (!isAdmin && step.id === 'canceled') return false;

  return true;

});

 

 

Tanushree Maiti
Tera Patron

Hi @ponranjitha 

 

Using Workspace Client script , you can achieve it

 

  1. Navigate to System Definition > Client Scripts
  2. Click New and configure:
    • Name: Hide Custom States in SOW.
    • Table: Change Request (change_request).
    • Type: onLoad.
    • UI Type: All or Mobile / Service Portal (Workspaces use the modern UI framework).
    • Global: Uncheck this box.
    • View: Set this to Service Operations Workspace

 

function onLoad() {

    // Remove the custom state options by their values

    g_form.removeOption('state', 'YOUR_CUSTOM_VALUE_1');

    g_form.removeOption('state', 'YOUR_CUSTOM_VALUE_2');

}

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti