- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-06-2024 05:46 AM
Hey, I have a request to make a UI action (Button) that save the record even if there is a variables that are not filed. I managed to disable the form mandatory field but not the variables. is there a way to catch the variables and disable them from UI action ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-08-2024 10:25 AM
Hi everybody, I found the solution. I will add the implmentation here.
my request was to make the UI action button "Save" to Ignore the mandatory fields in catalog task.
I have couple of variables that the user dose not fill but are mandatory for the ones who are working on the task.
I wanted to be able to save the task like if I changed the assign to or something else without fulfilling the mandatory fileds. once I press "close complete" then I want the mandatory to work as it should be.
the main problem was how to catch the variables in catalog task. I created a useful script that helps with that.
UI action
name : save
client : true
action name : sysverb_update_and_stay
script below
function saveProject() {
var fields = g_form.getEditableFields();// get all editable fields
for (var x = 0; x < fields.length; x++) {// for loop to each editable fields
g_form.setMandatory(fields[x], false);//remove mandatory of the fields
if (fields[x].substring(0, 5) == 'ni.VE') {//now I checked the variables on the catalog task
var newDLName = fields[x].substring(5);//I removed the first 5 letters of the variable name. because here we got the ni.VE******* (ni.VI is the first 5 letters and the '*' is the sys id of the field)
var gr = new GlideRecord('sc_item_option');//i search the field in this table
gr.addQuery('sys_id', newDLName);
gr.query();
if (gr.next()) {
var mr = new GlideRecord('item_option_new');//then I search the variable in this table
mr.addQuery('sys_id', gr.item_option_new);
mr.query();
if (mr.next()) {
g_form.setMandatory(mr.name, false);//set the variable mandatory false
}
}
}
}
gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');//save and stay
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-06-2024 05:53 AM
Hi @eyal abu hamad ,
Its not about the UI action (SAVE) which is restricting form submission. If there are any mandatory fields, submisison will not happen in any case.
To prevent mandatory in sc_task level, when you create UI policies or client scripts uncheck this check box to not to work on task level.
š
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-06-2024 05:59 AM
you missing my point. I want to disable mandatory variables in the catalog task only for saving for example new short discerption. I want to the variables to stay mandatory for closing the catalog task.
I need in the UI action to disable mandatory for the variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-06-2024 06:03 AM
@eyal abu hamad
please be noted that if it is saving the form or closing the task, there should be a mandatory server call. In this scenario, if there is server call happening, you cannot bypass mandatory fields. Only way is to uncheck the options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-06-2024 05:55 AM
Hi @eyal abu hamad ,
You can create a UI policy on your catalog item to make variables mandatory and make it only work on the catalog item view (portal).