scratchpad field set readonly for non ServiceDesk group

ServiceNow Use6
Tera Guru

Hi,

 

I am trying to set a variable in the catalog item to read only for other than Service Desk group at the sc_req_item level. I tried it but still non Service Desk group is able to edit it. Kindly help.

 

1.jpg

 

2.jpg

 

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

    if(gs.getUser().isMemberOf('Service Desk'))
	{
        g_scratchpad.variable = true;
    }

})(current, previous);

 

3.jpg

 

function onLoad() {
   
   if(g_scratchpad.variable!=true){
	g_form.setReadOnly('features', true);
   }
   
}

 

4.jpg

 

Regards

Suman P.

1 ACCEPTED SOLUTION

Hi @Ankur Bawiskar,

I am definitely not as good as you, but I can guarantee we can use g_scratchpad for catalog item. The only change i made is checking the checkbox in the catalog client script.

 

5.jpg

 

Regards

Suman P.

View solution in original post

9 REPLIES 9

Hi @Ankur Bawiskar,

I am definitely not as good as you, but I can guarantee we can use g_scratchpad for catalog item. The only change i made is checking the checkbox in the catalog client script.

 

5.jpg

 

Regards

Suman P.

@ServiceNow Use6 

Sorry my bad.

It does work.

Infact you missed that "Applies on Requested Item" checkbox

 

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

Ankur Bawiskar
Tera Patron
Tera Patron

@ServiceNow Use6 

g_scratchpad could not be used in catalog client script.

You will require normal onLoad client script instead of catalog client script

BR Script Updated

(function executeRule(current, previous /*null when async*/ ) {
	
        g_scratchpad.variable = gs.getUser().isMemberOf('Service Desk');
    
})(current, previous);

onLoad normal client script

function onLoad() {

    if (g_scratchpad.variable.toString() != 'true') {
        g_form.setReadOnly('features', 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

Vasantharajan N
Giga Sage
Giga Sage

@ServiceNow Use6 - Please use onLoad client script with GlideAjax for your requirement. As you cannot use g_scratchpad in the catalog client script on the catalog form. 


Thanks & Regards,
Vasanth

nityabans27
Giga Guru

Hi @ServiceNow Use6 ,

If you want Service Desk agents to be the only ones who can update after submission, use Variable Editor UI Policy. If you want to truly secure it (so even GlideRecord update scripts etc. can’t change it), store it as a field on sc_req_item and secure via ACLs.