getMissingFields and mandatoryCheck aren't work on Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 01:07 PM
Hello All.
Anyone know if function g_form.getMissingFields() and g_form.mandatoryCheck() aren't available on Agent Workspace?
While executing a function, the system throws console error:
"SCRIPT:EXEC Error while running Client Script "GlideScopedScript": TypeError: g_form.mandatoryCheck is not a function"
SCRIPT:EXEC Error while running Client Script "GlideScopedScript": TypeError: g_form.getMissingFields is not a function
Thank you, all.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 01:21 PM
Hello,
Yes these methods are not supported in workspace we can do it in opposite way though
g_form.getMissingFields() -- > this is used to get the empty fields which are mandatory .
g_form.mandatoryCheck();
- This method returns Boolean value and doesn’t have any parameter.
- What it Returns: Returns false if any of mandatory fields are not filled with value: otherwise returns true.
As these two are not available simple way to check for mandatory fields is like below
function filterForMissingMandatoryFields(field){
//check if field is mandatory
if(g_form.isMandatory(field)){
//return if there is no value
return !g_form.getValue(field);
}
}
function getMissingFields(){
//get all fields
var fieldList = g_form.getFieldNames();
//return only mandatory fields that have no value
return fieldList.filter(filterForMissingMandatoryFields)
}
getMissingFields();
Please accept this solution of it answers your question