Ignore mandatory fields while submitting a form in Agent Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2019 02:51 PM
Hi,
I'm trying to update the "Assign to me" button in Agent Workspace, so that it will change the assigned_to value to the current user even if they haven't filled out the mandatory fields on the form. The fields are set as mandatory through the dictionary reference, for example:
On a standard platform form, I can succesfully save the form by calling g_form.checkMandatory = false; before saving, but this property doesn't seem to be available in Workspace according to this document.
I've worked around this by using the following client script, but it's quite slow (takes a second for all field items to be iterated through, and also the form jumps around a little bit as the '*'s are removed), and I was wondering if there's a better way to do it:
function onClick(g_form) {
g_form.setValue('assigned_to', g_user.userID);
// set all fields as not mandatory
var allFields = g_form.getFieldNames();
for (var fieldName in allFields){
g_form.setMandatory(allFields[fieldName], false);
}
g_form.submit('sysverb_ws_save');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2021 08:33 AM
This won't work in the Agent Workspace.
The console gives an error message "g_form.getMissingFields is not a function"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2022 07:55 AM
Hi Pawan,
I am still getting the error that Sean was getting: g_form.getMissingFields is not a function
Is there something you've found that enables this function for use in workspace?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2022 12:28 AM
Hi Dustin,
Actually g_form.getMissingFields(), we used in earlier ServiceNow days, but I don't see this in the documentation of Snow, but still it can be used fine in the Client Script or similar scripts on Platform side, like Catalog client script, UI script etc., without enabling anything.
I think it will not work in workspace and Service Portal. Check this link for more info here
Regards
Pawan K Singh