To make variables mandatory when the 'closed complete' or 'closed incomplte' are clicked on a catalog task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2017 04:30 AM
HI all,
I have a requirement where I have to make certain fields mandatory when clicked on closed complete or closed incomplete buttons on a catalog task.
I have written the following client script on the variable set:
Tyoe : onSubmit
function onSubmit() {
if(g_form.getValue('state') == '3')
{
g_form.setMandatory("variables.var1", true);
g_form.setMandatory("variables.var2", true);
}
}
But it is not working. please help.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2017 04:34 AM
Hi Roger,
Add below statement at the end of the code:
return false;
Hope this might be helpful.
If the reply was informational, please like, mark as helpful or mark as correct!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2017 04:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2017 04:53 AM
Hi,
If you are having buttons on the Catalog task form for setting the state as Close Complete or Incomplete, then in order to make certain fields mandatory you need to update your UI action as mentioned below:
1) Mark the Client Checkbox on the UI Action form as true as shown in the below screenshot.
2) Provide an Action Name in the Action name field on the UI Action form and give some function name in the OnClick field on the UI Action form as shown below. This will allow you to make your UI action work both on Client as well on Server side as making fields mandate is something to be done on Client Side:
So in the above screenshot , Onclick on Close task button I am making the Description field as mandatory. You can refer the same for your Buttons.
Note: In Line Number 4 of the Script the Action Name should be same as the Action Name defined in the Action field on the UI Action form, so replace accordingly for your script.
Result:
You can refer the below link also for more details on how to use the UI Actions on both Client & Server Side:
https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2017 04:57 AM
Hi Suseela,
I have added return false; at the end of the code and it still didnt work.
function onSubmit() {
if(g_form.getValue('state') == '3')
{
g_form.setMandatory("variables.var1", true);
g_form.setMandatory("variables.var2", true);
return false;
}
}