Requester details field hiddenin the RITM and SCTASK form.

nageswari1
Tera Contributor

Hi Team,

 

I have got a requirement that, there is one field (Password) in the catalog item called "Password reset". After ticket creation, we generally see the password field in the Requester details under RITM form. In that RITM form I want it to be visible only for the specific group members. for rest of group members, it should be hidden in the Requester details section.

Conditions:
1. The field should be visible only to the specific assignment group members rest of members should be hidden.

 

I have tried creating a UI policies, but as the field is in the requester details, unable to select the field from the dropdown menu.

Can I know how can I achieve this?

 

Thanks in advance.

Nageshwari P.

1 ACCEPTED SOLUTION

Aniket Chavan
Tera Sage
Tera Sage

Hello @nageswari1 ,

@Ankur Bawiskar has already outlined the approach quite well, but since you specifically asked for steps, here’s a clear breakdown that you can follow to achieve this:

 

Step 1: Create a System Property

This will help you manage the group visibility without modifying scripts later.

  • Name: x.company.visible.password.group

  • Type: String

  • Value: (Enter the Sys ID of the assignment group whose members should see the field)

Step 2: Create a Display Business Rule on sc_req_item

This rule checks whether the logged-in user is a member of the allowed group and stores a flag in g_scratchpad.

(function executeRule(current, previous) {
    var allowedGroupSysId = gs.getProperty('x.company.visible.password.group');

    var isVisible = false;
    var groupMember = new GlideRecord('sys_user_grmember');
    groupMember.addQuery('user', gs.getUserID());
    groupMember.addQuery('group', allowedGroupSysId);
    groupMember.query();
    if (groupMember.hasNext()) {
        isVisible = true;
    }

    g_scratchpad.show_password = isVisible;
})(current, previous);

 

Step 3: Create an onLoad Client Script on sc_req_item

Use this script to control the visibility of the variable using the scratchpad value.

function onLoad() {
    // Replace 'new_password' with the name (not label) of your variable
    g_form.setDisplay('variables.new_password', g_scratchpad.show_password);
}

 

🔹 Please mark Correct if this solves your query, and 👍 Helpful if you found the response valuable.

 

Best regards,
Aniket Chavan
🏆 ServiceNow MVP 2025 | 🌟 ServiceNow Rising Star 2024

View solution in original post

18 REPLIES 18

Ankur Bawiskar
Tera Patron
Tera Patron

@nageswari1 

you can use this approach

1) display business rule on sc_req_item, check if logged in user is member of that group store that flag in g_scratchpad variable

2) onLoad client script on sc_req_item table and use that scratchpad variable and use the syntax I shared below to show/hide variable

g_form.setDisplay('variables.variableName', true);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

nageswari1
Tera Contributor

Hi @Ankur Bawiskar ,


Can you please help me with the code to achieve this?

 

Best Regards,

Nageshwari P

@nageswari1 

I suggest to start from your side as it will be learning for you as well.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Aniket Chavan
Tera Sage
Tera Sage

Hello @nageswari1 ,

@Ankur Bawiskar has already outlined the approach quite well, but since you specifically asked for steps, here’s a clear breakdown that you can follow to achieve this:

 

Step 1: Create a System Property

This will help you manage the group visibility without modifying scripts later.

  • Name: x.company.visible.password.group

  • Type: String

  • Value: (Enter the Sys ID of the assignment group whose members should see the field)

Step 2: Create a Display Business Rule on sc_req_item

This rule checks whether the logged-in user is a member of the allowed group and stores a flag in g_scratchpad.

(function executeRule(current, previous) {
    var allowedGroupSysId = gs.getProperty('x.company.visible.password.group');

    var isVisible = false;
    var groupMember = new GlideRecord('sys_user_grmember');
    groupMember.addQuery('user', gs.getUserID());
    groupMember.addQuery('group', allowedGroupSysId);
    groupMember.query();
    if (groupMember.hasNext()) {
        isVisible = true;
    }

    g_scratchpad.show_password = isVisible;
})(current, previous);

 

Step 3: Create an onLoad Client Script on sc_req_item

Use this script to control the visibility of the variable using the scratchpad value.

function onLoad() {
    // Replace 'new_password' with the name (not label) of your variable
    g_form.setDisplay('variables.new_password', g_scratchpad.show_password);
}

 

🔹 Please mark Correct if this solves your query, and 👍 Helpful if you found the response valuable.

 

Best regards,
Aniket Chavan
🏆 ServiceNow MVP 2025 | 🌟 ServiceNow Rising Star 2024