How to make variables editable for the users from a particular group

Kiruthika J
Tera Contributor

Hi All,

I have a requirement where two variables in RITM and SCTASK should be editable only for the users who are part of specific group and should be editable by admin as well.

 

Please help here.

Thanks!

4 REPLIES 4

Rajesh Chopade1
Mega Sage

Hi Kiruthika

 

You can use 'catalog UI policy' to make variables to be editable to any group.

 

mark my answer correct and helpful if if helps you to resolve the issue.

thanks

Rajesh.

The SN Nerd
Giga Sage
Giga Sage

This can be achieved without any scripting!

  1. Create a role
  2. Add the role to the group
  3. Add the role to 'write' for your variables (Permissions tab)

This solution is also scalable. If other groups need it, just add the role!


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Not through roles, Using group only.

Ankur Bawiskar
Tera Patron
Tera Patron

@Kiruthika J 

I would prefer solution shared by @The SN Nerd .

But if you wish to take other route then you can use Display BR on RITM and SC Task table

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	g_scratchpad.isMember = gs.getUser().isMemberOf('Group ABC'); // give your group name here

})(current, previous);

Then use onLoad normal client script on RITM and SC Task table and not catalog client script and script like this

function onLoad(){
	if(g_scratchpad.isMember.toString() == 'true' || g_user.hasRoleExactly('admin')){
		// do nothing
	}
	else{
		g_form.setReadOnly('variables.variableName1', true);
		g_form.setReadOnly('variables.variableName2', true);
	}
}

OR

1) onLoad catalog client script which Applies on Requested Item and Applies on Catalog Task

2) use GlideAjax and check for group membership

I hope you can do this requirement considering the approach I gave.

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