
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2019 04:01 PM
Hi friends,
While cancelling a change through UI Action the mandatory fields should be become non-mandatory. Below is my UI action "Cancel Change" code.
"new Workflow().cancel(current);
current.state=10;
current.u_rejected_change=true;
current.update();
var wf = new Workflow();
wf.cancel(current);
var curTasks = new GlideRecord('change_task');
curTasks.addQuery('change_request', current.sys_id);
curTasks.query();
while(curTasks.next()){
curTasks.state = 4;
curTasks.update();
}
action.setRedirectURL(current);"
Please suggest.
Thank You,
Karthik
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 12:37 PM
You would place this in the client script portion of your UI action.
So if you follow that link and see how to make your UI action both server side and client side capable...your client side would just be that code I put above.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2019 06:02 PM
Hi,
You'd need to make your UI Action dynamic in that it uses both server-side code (as you've used above) as well as client side...to force the Mandatory fields to not be mandatory.
Please use this link for reference how to use both client and server side code in UI Action: https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
And for the client side portion, you'd want to use this:
g_form.checkMandatory = false;
Please mark reply as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 10:12 AM
Hi Allen,
I really appreciate your response. Can you please suggest me where do I need to include the mandatory code in my script?
Thank you,
Karthik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 12:37 PM
You would place this in the client script portion of your UI action.
So if you follow that link and see how to make your UI action both server side and client side capable...your client side would just be that code I put above.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 02:10 PM
Thank You Allen,
Your response worked for my requirement.
Thanks,
Karthik