Make mandatory fields non-mandatory

karthikbabu
Giga Expert

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

 

1 ACCEPTED SOLUTION

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!

View solution in original post

5 REPLIES 5

Allen Andreas
Administrator
Administrator

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!

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

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!

Thank You Allen,

 

Your response worked for my requirement.

 

Thanks,

Karthik