Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Make some variables editable in catalog item Requested form(sc_req_request) for a group of users

Rahul21
Mega Contributor

Hello Experts,

 

 

Now in my catalog item requested form the variables are read only, I want to make the variables editable for the particular group. Please suggest.

 

How to achieve this functionality.

 

 

2 REPLIES 2

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Rahul ,  

 

Client Script :- OnLoad on RITM  

 

function onLoad() {
var ritm = g_form.getValue('request_item');
var ag = g_form.getValue('assignment_group');
var usr = g_user.userID;
var ga = new GlideAjax("userUtils"); //name of script include
ga.addParam("sysparm_name","getDetails"); //name of function
ga.addParam("sysparm_user", usr);
ga.getXMLAnswer(callBack); //name of call back function

function callBack(answer) {
if(answer == 'not editable'){
g_form.setVariablesReadOnly(true);
}
}
}

 

 

Script Include:-  Checkbox check: Client Callable

var userUtils = Class.create();
userUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getDetails: function(){
var answer = 'editable';
var usr = this.getParameter("sysparm_user");

if(!gs.getUser(usr).isMemberOf('sys_id of group')){
answer = 'not editable';
}
return answer;
},

type: 'userUtils'
});

 

 

 

Please mark my answer as helpful/correct if it resolves your query.

 

Regards,

Gunjan Kiratkar

Consultant - ServiceNow, Cloudaction

Rising Star 2022

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Hi gunjan,

 

var ritm = g_form.getValue('request_item');  - What we have to pass in (request_item) 

Is it should be the name of catalog item?