how to make variables edited on sc_task's/ritm when request is open and after request is in closed state sc_task 's/ritm variables should be read-only.

Santhosh15
Tera Guru

Hello,

Could you please suggest, how to make the particular variables read-only, when all catalog task get closed.

If one catalog is open state and another catalog task is closed state, then the variable should be editable for both the task.

If both the catalog task are in closed state, then only the variable should be in read-only state in both the task.

I written below code in catalog client script on onload form applied to catalog task and Requested item.

But the request item variables are not making read-only, when ritm is close complete.

function onLoad() {

var ritm = g_form.getReference('request_item', callBackMethod);
alert("ritm");
}

function callBackMethod(ritm) {

if (ritm.state == '3' || ritm.state == '4' || ritm.state == '7') {
alert("testing");
g_form.setVariablesReadOnly(true);
}

}

Could you please help on this issue.

Thank you

 

@Ankur Bawiskar 

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@D Kumar Swamy 

try to update script as this to make it work for sc_req_item and sc_task

function onLoad() {

	if(g_form.getTableName() == 'sc_task')
		var ritm = g_form.getReference('request_item', callBackMethod);
	else{
		var state = g_form.getValue('state');		
		if (state == '3' || state == '4' || state == '7') {
			g_form.setVariablesReadOnly(true);
		}
	}
}

function callBackMethod(ritm) {
	if (ritm.state == '3' || ritm.state == '4' || ritm.state == '7') {
		alert("testing");
		g_form.setVariablesReadOnly(true);
	}
}

Regards
Ankur

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

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@D Kumar Swamy 

try to update script as this to make it work for sc_req_item and sc_task

function onLoad() {

	if(g_form.getTableName() == 'sc_task')
		var ritm = g_form.getReference('request_item', callBackMethod);
	else{
		var state = g_form.getValue('state');		
		if (state == '3' || state == '4' || state == '7') {
			g_form.setVariablesReadOnly(true);
		}
	}
}

function callBackMethod(ritm) {
	if (ritm.state == '3' || ritm.state == '4' || ritm.state == '7') {
		alert("testing");
		g_form.setVariablesReadOnly(true);
	}
}

Regards
Ankur

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

Thank you so much Ankur, this script is worked

@D Kumar Swamy 

Glad to know.

Please mark response helpful as well.

Regards
Ankur

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