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
01-17-2023 07:05 AM
rename your action name to "sysverb_cancel"
just add below to your script nothing else you need
action.setRedirectURL(current);
current.update();
There is other way
you can keep action name anything
onClick - SkipandSave()
script:
function SkipandSave() {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setMandatory(fields[x], false);
}
gsftSubmit(null, g_form.getFormElement(), 'your action name');
}// no need to write update and redirect
Thanks,
Bharath
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 08:35 AM
Thanks, but I don't think this solves my issue. My "Save" button works perfectly fine unless somehow clicks "Update" or "Close Task" which alerts about mandatory fields not being populated. Then the "Save" I created will not work as it will also alert on mandatory fields being populated.
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
01-17-2023 08:56 AM
@Steven Parker if you use above mentioned script it will by pass those scenarios also.
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 10:45 AM
Are you saying your Save button works unless someone clicks a different button (Update or Close Task)?