- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 10:07 AM
I have a catalog item and there are 3 variables which will be visible and mandatory after the submit of the request. The person who is going to work on the task, has to fill the values in it .
I m using the below script on load and made it as "Applies on Requested Items/Tasks" and on "Catalog view". The questions appear as mandatory after submit of the request with this script. i m not able to save the RITM without entering any values for these variables. But if i close the task, the RITM is getting closed..
How to handle this scenario
var isAdmin = g_user.hasRole('admin');
var isCatalogMaster = g_user.hasRole('catalog_master');
if (isAdmin || isCatalogMaster) {
// alert('Current user is an admin');
//g_form.setVisible('current_priority', true);
g_form.setMandatory('quality_standards_outcome', true);
g_form.setMandatory('performance_standards_outcome', true);
g_form.setMandatory('security_standards_outcome', true);
}
else
{
g_form.setMandatory('quality_standards_outcome', false);
g_form.setMandatory('performance_standards_outcome', false);
g_form.setMandatory('security_standards_outcome', false);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 10:42 AM
Hi Kailash,
There is a column Global, not visible on form.
Add it to the list view and mark these variables global.
They are important on the catalog task, because an engineer would look at task and not the RITM, while fulfilling a request
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 10:42 AM
Hi Kailash,
There is a column Global, not visible on form.
Add it to the list view and mark these variables global.
They are important on the catalog task, because an engineer would look at task and not the RITM, while fulfilling a request
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 10:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 11:09 AM
I have one more question on Transform map.. Below is the script which i have written for inserting the comma separated values to the List.. Actually for Reference fields we have the option to "Create". So if the values listed in excel was not there in the reference table, it will get added.. For "List" we dont have such option, so here is the logic which i m using to insert the records
- Split the input into an array
- Loop through the Array and insert the records one by one
- Not all the records will be inserted because of the Business rules on the table. If the input not matching specific criteria, then it shouldnt get added
- Next i query the table with the given input and display it on the List
- Say for example, i have values 1.mac, 2.xls and 3.t.. The last value will get failed during insertion bcause its not valid...And again while adding it to the List, i should display only 1.mac and 2.xls.. so i m doing the second query
Question
- Now the question is, to somehow, i feel i m causing performance issues and it can be done much easier.. For example, instead if inserting records one by one , can i do a bulk insert?
Also instead of doing two times the query , one for inserting records to the main table and the next one is to display the values in the List, can it be done in a single query altogether?
var filenameArr=[];
var filenameArrDup=[];
var filenames=source.u_file_name;
var valid =[];
var isExist='';
filenameArr = filenames.split(',');
filenameArrDup=filenameArr;
for(var i=0;i<filenameArr.length;i++){
var filenameRec=new GlideRecord('x_opt_macro_govern_macro_file_names');
filenameRec.addQuery('file_name',filenameArr[i]);
isExist='no';
while(filenameRec.next()){
isExist='yes';
}
if(isExist=='no'){
filenameRec.file_name=filenameArr[i];
filenameRec.active='true';
filenameRec.insert();
}
}
var filenameRecQuery=new GlideRecord('x_opt_macro_govern_macro_file_names');
filenameRecQuery.addQuery('file_name','IN',filenameArrDup);
filenameRecQuery.query();
while(filenameRecQuery.next()){
valid.push(filenameRecQuery.getValue('file_name'));
}
return valid;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 11:24 AM
Below code should do the same thing.
var filenameArr=[];
var filenameArrDup=[];
var filenames=source.u_file_name;
var valid =[];
var isExist='';
filenameArr = filenames.split(',');
//filenameArrDup=filenameArr;
for(var i=0;i<filenameArr.length;i++){
var filenameRec=new GlideRecord('x_opt_macro_govern_macro_file_names');
filenameRec.addQuery('file_name',filenameArr[i]);
if (!filenameRec.next()){
filenameRec.file_name=filenameArr[i];
filenameRec.active='true';
filenameRec.insert();
}
}
return filenameArr;
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 12:03 PM
But the problem is, if the input is "fil.xls,fil.xlsm,fil.te,fil.mac"
filenameArr will be having the value of "fil.xls,fil.xlsm,fil.te,fil.mac" and "fill.te" is not inserted into filename table but it will display on my List field..The list field is on another table and it s having reference to file name table
And one more query from the original post.. since i had only one task, we made the variable as Global and it worked perfectly fine.. if i have two tasks, how would i ensure that the variable should be appearing on one task only??