- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:27 AM
Hi All
I am trying to tweak the UI action ->Workspace Client Script below
with either g_form.checkMandatory = false;
or
for (var i = 0; i < g_form.elements.length; i++)
{
var el = g_form.elements[i];
var fieldName = el.fieldName;
g_form.setMandatory(fieldName, false);
}
to make the mandatory fields on the form not mandatory so that on button click the new form opens. The below works when all mandatory fields are completed but I need it to work when the mandatory fields are still unanswered.
Any suggestions greatly appreciated. Thanks!
===================================
function onClick() {
var result = g_form.submit('sysverb_ws_save');
if (!result) {
//failed form submission
return;
}
result.then(function() {
var params ={};
params.sysparm_parent_table = "xxxxxxxxx";
params.sysparm_parent_sys_id = g_form.getUniqueValue();
g_service_catalog.openCatalogItem('xxxxxxx', '-1', params);
});
}
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2020 05:34 AM
Solved it with using g_form.getFieldValues.... instead of
g_form.elements.length;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:36 AM
Hi,
Where is this part of code:
for (var i = 0; i < g_form.elements.length; i++) { var el = g_form.elements[i]; var fieldName = el.fieldName; g_form.setMandatory(fieldName, false); }
In Workspace script or normal script box at top.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:50 AM
I tried it in both workspace cs and normal cs but couldn't get this to work
in workspace cs I added it to after function onClick() {
I don't even need to save the work I just want to leave the form and go to the new form that will open in workspace which as mentioned does happen when I click on this button with all mandatory fields completed

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:39 AM
try something like this. make all the fields non- mandatory before submiting the form.
function onClick() {
for (var i = 0; i < g_form.elements.length; i++)
{
var el = g_form.elements[i];
var fieldName = el.fieldName;
g_form.setMandatory(fieldName, false);
}
var result = g_form.submit('sysverb_ws_save');
if (!result) {
//failed form submission
return;
}
result.then(function() {
var params ={};
params.sysparm_parent_table = "xxxxxxxxx";
params.sysparm_parent_sys_id = g_form.getUniqueValue();
g_service_catalog.openCatalogItem('xxxxxxx', '-1', params);
});
}
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:52 AM
I tried this but didn't work 😞