- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 08:19 PM
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);
}
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 09:34 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 08:54 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 09:34 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 09:40 PM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2018 02:12 AM
Thanks all,
Ashutosh's code worked perfectly!
Cheers,
Brendan!