- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2023 08:44 AM
Hi,
On the incident form we have Assigned To as a mandatory field. I am trying to setup a UI action that automatically sets the logged in user to be assigned to the incident. However since the field is mandatory I am being prevented from continuing when clicking on the UI action. Is there some way for my UI action to ignore this requirement or a different route to get this solution? Below is my UI action and what is happening when user clicks the UI action.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2023 09:16 AM - edited ‎08-15-2023 09:17 AM
Hi @Jared Wason ,
1. On UI action form we have Client check box select that and give function name n onClick field and use below code.
Refer below
function setAssigneee(){
g_form.setMandatory('assigned_to',false);
g_form.setValue('assigned_to',g_user.userID);
g_form.save();
}
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2023 09:16 AM - edited ‎08-15-2023 09:17 AM
Hi @Jared Wason ,
1. On UI action form we have Client check box select that and give function name n onClick field and use below code.
Refer below
function setAssigneee(){
g_form.setMandatory('assigned_to',false);
g_form.setValue('assigned_to',g_user.userID);
g_form.save();
}
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2023 09:39 AM
@Jared Wason You can create UI action as below. It will take care of all mandatory fields once you click on "Assign to Me" UI action.
Client checkbox should be checked and put "callClientScript();" in onClick field.
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(), "incident_assign_to_me");
}
if (typeof window == 'undefined')
serverScript();
function serverScript() {
current.assigned_to = gs.getUserID();
current.update();
action.setRedirectURL(current);
}
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!