Save UI Action on Catalog Task table - Ignore Mandatory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 05:20 AM - edited 01-17-2023 05:21 AM
So I created a new "Save" UI Action that will allow people to save a catalog task without populating mandatory fields. This works great, but the one issue I can't figure out is if they accidentally click "Close Task" or "Update", then they are alerted the mandatory fields haven't been filled, like normal, and the field now has a red box around it that can't be by-passed by my new "Save" UI Action. So essentially, with that red box around the field my new "Save" UI Action alerts the same as all the rest that a mandatory field needs to be filled in. How can I modify my "Save" UI Action code to ignore this as well or remove focus from the field or any other method?
Here is the UI Action script:
//Client-side 'onclick' function
function u_saveRecordClient(){
//ignore mandatory fields
var state = g_form.getValue('state');
//we can save without filling in all mandatory fields and variables if the task is not closed or closing
if (g_form.getValue('state') != 3){
g_form.checkMandatory = false; //ignore mandatory fields
try {
//now ignore any mandatory variables
var allVariables = document.getElementById('variable_map').getElementsByTagName('item');
for(var i = 0; i < allVariables.length; i++){
var item = allVariables[i];
g_form.setMandatory('variables.' + item.getAttribute('qname').toString(),false);
}
} catch(err) {}
}
//Call the UI Action and skip the 'onclick' function
//this will execute the code below
gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay'); //MUST call the 'Action name' set in this UI Action
}
//Code that runs on the server, without 'onclick'
//Ensure call to server-side function with no browser errors
if(typeof window == 'undefined')
u_saveRecordServer();
function u_saveRecordServer() {
action.setRedirectURL(current); //come back to the same record
current.update();
}
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 01:14 AM
Not sure if you have already figured this out, but once you click the Close Task button it sets the Status field to Closed Complete (state=3) on the form so have the Status field displayed on the form so user can change it to something else and and save again. if not you can set it to a different sate in the script and save.