How to hide cancel button on RITM Record

Sachin G K1
Kilo Sage

Hi Team,

 

I want to hide cancel button to particular group of user on some particular catalog items RITM record. How to achieve this req?

SachinGK1_0-1684925262183.png

 

 

 

Thanks in Advance

 

2 REPLIES 2

Amit Gujarathi
Giga Sage
Giga Sage

HI @Sachin G K1 ,
I trust you are doing great.

  1. Identify the catalog item for which you want to hide the cancel button.

  2. Determine the group of users who should not have access to the cancel button.

  3. Navigate to the catalog item's form in the ServiceNow instance.

  4. Switch to the Form Design view for the catalog item.

  5. Locate the cancel button element on the form.

  6. Open the cancel button properties and find the "Visible" property.

  7. Modify the visibility condition to exclude the group of users who should not see the cancel button. You can use GlideRecord queries or ACL conditions to achieve this.

You can add the below script in script include and call it in UI action condition

if (gs.hasRole('admin')) {
    // Show the cancel button for admin users
    current.variables.cancel_button.visible = true;
} else {
    var userGrp = gs.getUser().getMyGroups();
    if (userGrp && userGrp.indexOf('group_name') >= 0) {
        // Hide the cancel button for users in the specified group
        current.variables.cancel_button.visible = false;
    } else {
        // Show the cancel button for all other users
        current.variables.cancel_button.visible = true;
    }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



I am unable to find Cancel button of ritm record in form design and is there any general solution for this, so that we can specify the list of catalog item ritm in which we wish to hide