
- 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
10-18-2021 09:23 AM
You can try below code on UI action. It will work.
function callClientScript() {
//Client Script
var arr = g_form.getMissingFields();
for (var x = 0; x < arr.length; x++) {
g_form.setMandatory(arr[x], false);
alert("Following fields are set Non Mandatory: " + arr[x]);
}
gsftSubmit(null, g_form.getFormElement(), 'update_to_p1'); // UI action name
}
if (typeof window == 'undefined')
callServerScript();
function serverScript() {
// Server Script
current.update();
action.setRedirectURL(current);
}
Please mark answer helpful if it helped.
Regards
Pawan K Singh