Client Script on Task table, how to exclude from change_request table

Brendan Hallida
Kilo Guru

Hi all,

 

I have the below client script that we created by our implementer, which sets the next steps that you can select in that field.  it also makes the state field read-only when it meets the conditions.

We are in the middle of a rework of the change form, to bring it back closer to how it is OoB.  it was highly customised when implemented (before my time).

Since we will be scrapping the next step feature, we need this client script to not be running, however, the problem is that this script is sitting on the task table.  Incident still uses this and we will be getting to incident later in the year. 

Is there a way to exclude the change_request table inside the client script?

 

Thanks in advance!

function onLoad() {
	
	// decode the JSON encoded status flow and set the next steps on the form, if needed
	if (g_scratchpad.nextSteps != undefined) {
		var nextSteps = g_scratchpad.nextSteps.evalJSON();
		
		if (nextSteps.valid) {
			// there was a defined status flow for this record, so make state readonly
			g_form.setReadOnly('state', true);
			// note that restrictNextStepChoices lives in a global UI Script: KS Status Flow Utilities
            restrictNextStepChoices(nextSteps);
		} else {
			// there was no defined status flow for this record, so make state writable
			g_form.setReadOnly('state', false);
		}
	}
}
1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

 

Use below script:

 

function onLoad() {

// decode the JSON encoded status flow and set the next steps on the form, if needed
if(g_form.getTableName() != 'change_request')
{
if (g_scratchpad.nextSteps != undefined) {
var nextSteps = g_scratchpad.nextSteps.evalJSON();

if (nextSteps.valid) {
// there was a defined status flow for this record, so make state readonly
g_form.setReadOnly('state', true);
// note that restrictNextStepChoices lives in a global UI Script: KS Status Flow Utilities
restrictNextStepChoices(nextSteps);
} else {
// there was no defined status flow for this record, so make state writable
g_form.setReadOnly('state', false);
}
}

}
}

 

Thanks,
Ashutosh Munot

 

Please Hit Correct, Helpful or like,if you are satisfied with this response.

View solution in original post

7 REPLIES 7

Gurpreet07
Mega Sage

You could simply move the script to incident table or simply use 'if' condition at beginning. There will be a display business rule for setting the scratch-pad variables. That BR could be moved to incident table as well or you could leave that as is ...

 

if(g_form.getTableName() != 'incident')

return;

 

//code

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

 

Use below script:

 

function onLoad() {

// decode the JSON encoded status flow and set the next steps on the form, if needed
if(g_form.getTableName() != 'change_request')
{
if (g_scratchpad.nextSteps != undefined) {
var nextSteps = g_scratchpad.nextSteps.evalJSON();

if (nextSteps.valid) {
// there was a defined status flow for this record, so make state readonly
g_form.setReadOnly('state', true);
// note that restrictNextStepChoices lives in a global UI Script: KS Status Flow Utilities
restrictNextStepChoices(nextSteps);
} else {
// there was no defined status flow for this record, so make state writable
g_form.setReadOnly('state', false);
}
}

}
}

 

Thanks,
Ashutosh Munot

 

Please Hit Correct, Helpful or like,if you are satisfied with this response.

Kunal Jha
Giga Expert

Either make the client script as inactive or as suggested by other member try to filter out using condition

if(g_form.getTableName() != 'incident' || g_form.getTableName() != 'change_request') // and so on

return;

Brendan Hallida
Kilo Guru

Thanks all,

 

Ashutosh's code worked perfectly!

 

Cheers,

Brendan!