- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2021 12:31 PM
Hello Im looking for a way to have a vairable field be Mandatory if the Task is set to closed complete.
Basically not allow users to close the SCTASK without filling out the variable. something like this.
Any help is appreciated. Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2021 12:47 PM
I have this requirement often. An onSubmit Catalog Client Script that Applies on Catalog Tasks is the way to go. You only need one script per catalog item. You can, and probably will have many iterations of this requirement - this variable is mandatory on this task and that one, and this one is mandatory if the task is closed complete, incomplete, or skipped,... - all just modifications to the if statements below
function onSubmit() {
if(g_form.getValue('state') == 3){//Closed Complete
if(g_form.getValue('short_description') == 'Request a Knowledge Article'){//to make this variable mandatory when only this task closes
g_form.setMandatory('v_testing_field', true);
if(g_form.getValue('v_testing_field') == ''){
alert('Testing field is required');
return false;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2021 12:58 PM
this worked thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2021 01:01 PM
You are welcome!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2021 01:42 AM
I was just thinking about this today and was considering which is the best option.
Thought I would come to the community forums to see what people's opinions were.
The different technical solutions I thought about were:
- onSubmit Catalog Client Script
- Client Script on Catalog Task
- UI Policy on Catalog Task (with Script)
I landed on the last option and strongly believe it is the best option.
I think I might write a blog post about it, going into detail as to why. Watch this space.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2021 06:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2021 06:45 AM
I have started drafting my blog for my solution that is low code and maintainable.
Will post the link when I have published it :).
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022