Ignore mandatory fields while submitting a form in Agent Workspace

Sean61
Kilo Expert

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:

find_real_file.png

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');
}
7 REPLIES 7

This won't work in the Agent Workspace. 

The console gives an error message "g_form.getMissingFields is not a function"

Community Alums
Not applicable

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?

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