- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2017 08:09 AM
Currently using ISTANBUL
Objective: Create a second RITM under new REQ using script in Workflow. This RITM would then trigger it's corresponding workflow.
Details:
We have a Catalog Item (New Provider) that allows our organization to ask for a onboarding staff to have specific permissions in a medical setting. Training is also required for this new individual. There is a separate Catalog Item used by our training team that allows them to track completion and communicate requirements for New Providers and other similar REQs (generally submitted via email).
Our goal is that when a new Provider is ordered from the Service Catalog, it's corresponding workflow will contain an activity that will generate a second RITM for the Training team under the same REQ.
I tried adding the following script to the New Provider Catalog Item in the "Delivery Plan Script field. This didn't do anything at all which makes me wonder if I don't fully understand its purpose...or more likely, the script is faulty:
var reqItem = new GlideRecord('sc_req_item');
reqItem.initialize();
reqItem.request = current.request.sys_id;
reqItem.cat_item = '80df599bdba3320007a2fe1ebf9619ff'; //Sys_id of Training Catalog Item
reqItem.short_description = "Training Tracking for New provider";
reqItem.stage = "request_approved";
reqItem.approval = "requested";
reqItem.insert();
I added the same script to Run Script activity in the New Provider workflow. A second RITM was created under the same REQ...BUT (and it's a big one) the Training Workflow was not run or tied to the new REQ. I did search online and couple of posts directed me here, but that is what I tried first.
Any advice on what I am missing?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 02:59 PM
this is a script i use to create a number of new req items inside an existing request.. it is wrapped in a for loop since it is going to crerate multiple items.. just eliminate that loop... bottom line is FIRST you create the item... and associate to the current request.. THEN you go through and set all variables that you need.. so where i am setting the variables.. take mine out put in yours and add any lines needed to get em all..
my apologies to whoever i stole this code/idea from! this runs in a script box inside of your workflow.. obviously replace the sys_id i have in my code with your own<the sys id for the maintain item you are creating an item for>
list = current.variables.v_xxxx_additional_secured_area_acc.toString();
var list_split = list.split(',');
var secure_area = 'e891c69d13a1fe008e9c7e276144b03c'; //sid for the wecure item access
for(var counter = 0 ; counter< list_split.length; counter++){
//create a new item in the request
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request, secure_area, 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);
//find the item and update itsvariables
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.addQuery('request', current.request);
grReqItem.addQuery('cat_item',secure_area);
grReqItem.addQuery('parent','');
grReqItem.query();
if(grReqItem.next()) {
//gs.addInfoMessage('Found item ' + grReqItem.number);
grReqItem.variables.requested_for = current.variables.requested_for;
grReqItem.variables.v_area = list_split[counter];
grReqItem.parent = current.sys_id;
grReqItem.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 02:59 PM
this is a script i use to create a number of new req items inside an existing request.. it is wrapped in a for loop since it is going to crerate multiple items.. just eliminate that loop... bottom line is FIRST you create the item... and associate to the current request.. THEN you go through and set all variables that you need.. so where i am setting the variables.. take mine out put in yours and add any lines needed to get em all..
my apologies to whoever i stole this code/idea from! this runs in a script box inside of your workflow.. obviously replace the sys_id i have in my code with your own<the sys id for the maintain item you are creating an item for>
list = current.variables.v_xxxx_additional_secured_area_acc.toString();
var list_split = list.split(',');
var secure_area = 'e891c69d13a1fe008e9c7e276144b03c'; //sid for the wecure item access
for(var counter = 0 ; counter< list_split.length; counter++){
//create a new item in the request
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request, secure_area, 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);
//find the item and update itsvariables
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.addQuery('request', current.request);
grReqItem.addQuery('cat_item',secure_area);
grReqItem.addQuery('parent','');
grReqItem.query();
if(grReqItem.next()) {
//gs.addInfoMessage('Found item ' + grReqItem.number);
grReqItem.variables.requested_for = current.variables.requested_for;
grReqItem.variables.v_area = list_split[counter];
grReqItem.parent = current.sys_id;
grReqItem.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 10:51 AM
Raymond, this is great! If it was logistically possible, I would buy you the beverage of your choice. As it is, you get the honor of having your response marked as the Correct Answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 11:27 AM
my pleasure and glad i could help.. i actually found the code on the community site myself and hacked it to make it work for me grins... so we are both helped by whoever did it originally that is handy toy to have right there!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2018 04:08 AM
Hi Kevinthury,
Are you successful in creating multiple RITMs via Workflow?
If so, can you share the ideas here?
Thanks & Regards,
Ram Prakash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 05:42 AM
Hi,
Currently, it is creating only one RITM irrespective of the for loop condition.
I mean, it is not looping according to the list collector selection numbers.
Did you faced the same issue or it was successful?
Thanks & Regards,
Ram Prakash