Issue with g_form.elements.length in UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
I am using g_form.elements.length in workspace client script UI action. I am trying to bypass all mandatory fields and save data. It is working in regular form view, but not in workspace. Can we bypass all required fields in workspace and save form?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'm sorry but I don't understand the purpose of that requirement. If the fields are mandatory, why do you want to override it only on workspace? If you want to allow the users to submit the form, then you might as well set the fields to mandatory false on all views.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @pramodkumar
g_form.element is deprecated (Refer: GlideForm (g_form) - Client ).
While it works in the "Core UI" (standard platform), it will fail in Workspace because the underlying DOM structure is different and modern Workspace APIs enforce stricter isolation.
Instead of g_form.elements, use g_form.getEditableFields() to retrieve an array of field names. This method is compatible with Workspace.
Sample code: <write code as per your requirement>
function onClick(g_form) {
var fields = g_form.getEditableFields();
for (var i = 0; x < fields.length; i++) {
g_form.setMandatory(fields[i], false);
}
g_form.submit();
}
