Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Configuring Custom Tab Visibility in Workspace Based on Caller and Priority

SriharshaYe
Mega Sage

Use Case

The requirement is to control the visibility of a tab in the Workspace based on the Caller and Priority of the record.

The tab should be visible only when:

  • The Caller is Sentinel, and
  • The Priority is either P1 or P2.

For all other callers or priorities, the tab should remain hidden.

Step 1: Navigate to UI Builder
Step 2: Select the Required Page Collection
Step 3: Select the Custom Tab
Step 4: Open the Variant Settings
Step 5: Configure the Screen Condition

In the Screen Conditions section, add a script condition.

 

SriharshaYe_0-1789748121129.png

 

Use the following script:

(function scriptFunction(params) {

    var sentinelCallerSysId =
        gs.getProperty('sn_sow_inc.kap.Sentinel.Id');

    if (
        (params.data.caller_id == sentinelCallerSysId) &&
        (
            params.data.priority == '1' ||
            params.data.priority == '2'
        )
    ) {
        return true;
    } else {
        return false;
    }

})(inputProperties);

Step 6: Configure Parameter Mapping

The script requires the Caller and Priority values from the current record.

To provide these values to the script, configure the required parameter mapping.

SriharshaYe_1-1789748145839.png

Use the following param mapping:

{
    "type": "MAP_CONTAINER",
    "container": {
        "priority": {
            "type": "DATA_OUTPUT_BINDING",
            "binding": {
                "address": [
                    "record",
                    "form",
                    "fields",
                    "priority",
                    "value"
                ]
            }
        },
        "caller_id": {
            "type": "DATA_OUTPUT_BINDING",
            "binding": {
                "address": [
                    "record",
                    "form",
                    "fields",
                    "caller_id",
                    "value"
                ]
            }
        }
    }
}

Step 7: Save the Screen Condition

After adding the script and parameter mapping, save the Screen Conditions configuration.

Make sure that both the script and parameter mapping have been saved successfully.


Step 8: Verify the Tab Visibility

After saving the configuration, open the Workspace and test the tab with different Caller and Priority combinations.

0 REPLIES 0