- 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 06:00 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:23 AM
What have you tried so far?
try using the below if not already
g_form.checkMandatory = false;
- 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
}