How to hide a "Variable" on RITM and SCTASK form based on the user belongs to the group or not?

Naveen Kumar
Tera Contributor

There is a variable called Billing rate on SCTASK and RITM.

Need to show this field only to the users who belongs to "PPM Admin" group.

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Bharath kumar 

Steps

1) create a new role and add to your Group "PPM Admin"

2) then you can use catalog client script on your catalog item which applies on Requested Item and Catalog Task

Script

function onLoad(){

	if(!g_user.hasRoleExactly('roleName'))
		g_form.setDisplay('variableName', false);
}

Regards
Ankur

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

View solution in original post

2 REPLIES 2

Aman Kumar S
Kilo Patron

Hi @Bharath kumar 

You can create onLoad client script in the catalog item and mark True for "Applies on Requested item" and "Applies on Catalog task" and use Glideajax to check if user belong to the particular group and then hide or show fields on the form.

Function to use would be:

gs.getUser().isMemberOf("sys_id_of_PPM ADMIN group");// returns true if logged in user is member of the group.

Extending GlideAjax

 

Feel free to mark correct, if your issue has been resolved, so it ends up in solved queue.

Will be helpful for others looking for the similar query.

Best Regards
Aman Kumar

Ankur Bawiskar
Tera Patron
Tera Patron

@Bharath kumar 

Steps

1) create a new role and add to your Group "PPM Admin"

2) then you can use catalog client script on your catalog item which applies on Requested Item and Catalog Task

Script

function onLoad(){

	if(!g_user.hasRoleExactly('roleName'))
		g_form.setDisplay('variableName', false);
}

Regards
Ankur

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