Hiding Related Link based on condition

Blitz
Tera Expert

Hello, does anyone know how to hide a related link based on a condition?

Example: If state is in progress, then this related link will not show up. 

1 ACCEPTED SOLUTION

Vaishnavi Lathk
Mega Sage
Mega Sage

Hello,

 

  1. Configure the UI Action:

    • Name: Give your UI Action a descriptive name.
    • Table: Select the table where you want the related link to appear (e.g., incident).
    • Action name: Provide an action name (e.g., hide_related_link).
    • Show Insert: Check this if you want the link to be available on new records.
    • Show Update: Check this if you want the link to be available on existing records.
    • Condition: This is where you'll add the condition to hide the related link.

Sample Condition Script

Here's an example condition script that hides the related link if the state is "In Progress":

 

// Check if the current record's state is "In Progress"
// Replace `state` with the actual field name if it's different
// Replace `2` with the actual value for "In Progress" if different
current.state == 'In Progress';

 

Regards,

Vaishnavi Lathkar

View solution in original post

8 REPLIES 8

Is there a script in the script field for this configuration ? like if conditions 

Hello Blitz,

To apply conditions at the script level and ensure related links are not hidden based on specific states, you need to utilize the conditions field provided in the ServiceNow UI action. This approach allows you to specify the criteria under which related links should be displayed or hidden, ensuring that the links remain visible or become hidden according to the defined states. By configuring the conditions field appropriately, you can achieve the desired behavior for related links based on the specific conditions you have set.

Valmik Patil1
Kilo Sage

Hello Blitz,

You can make use of condition field on UI action.

please refer below screen shot for you reference

ValmikPatil1_0-1717131745740.png

Thanks,

Valmik Patil

 

Rohit99
Mega Sage

Hi @Blitz ,

 

Please find the attach screenshot.

 

UI action condition.PNG

In condition => current.state != '2 ' here '2' is backend name of In progress state.

 

 

Please mark my response as correct and helpful if it helped solved your question.

 

Thanks,

Rohit Suryawanshi