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

HI @Aniket Chavan ,

 

Yes, It is worked.
But when I am previewing the RITM ticket from SCTASK form, We are able to view the Password field in preview.
We need to hide the field from preview as well.

Can you please help me how to acheive this.

 

Best Regards,

Nageshwari P

nageswari1
Tera Contributor

Hi @Aniket Chavan 

 

Yes, It worked.
But when the RITM is previewed from the SCTASK form, the password field is visible to all the users.
It should not visible to all the users. It should be hidden in preview section as well.
Can you please help me with this how to achieve this.

 

Best Regards,

Nageshwari P.

Hey @nageswari1 @Nageshwari P can you please share some screenshots? so that i can understand better about the preview you are talking about..........

Hi @Aniket Chavan,

I have created few fields for reference in PDI.

Please find the screenshot I have attached.
When I am previewing RITM from SCTASK form. In Variables I can see the fields right.
There I need to hide the "Password" field for all the groups except one.
I have followed your above steps and I can hide the "Password" field in RITM form and SCTASK form. But the field is getting visible when Checking from the preview option.

Can you please help me with this?

 



Ex: In screenshot, I referred to User ID.

@nageswari1 @Nageshwari P ALso I think your original ask was for the form only and thats completed so you can close this thread by accepting my answer which helped you initially and then open new one for the another related issue you are facing......