- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2015 04:01 PM
I need to add an item to an existing request.
The workflows require that certain variables exist and I'll need them to be visible in later tasks.
Some time ago (Calgary) I attempted to create them manually. However, this caused a problem in that, while I could access the variables, I could not display them in tasks.
The only solution that was proposed was creating a request item by using the Cart API to create a new cart and request.
The Cart API doesn't appear to have any options for adding to an existing request, and the only "solution" I've found in the community, is to create the Request item in this way, then delete the request.
Obviously this is a really ugly solution, especially since it kicks off tasks and workflows before I have a chance to delete it.
Is there a better solution that I'm just not finding?
Thanks,
-Stephen
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2015 08:54 AM
Hi Stephen,
Have you tried to create a new RITM within the same REQ using GlideappCalculationHelper? I found it awhile back, either here on the Community or some other site, but it's helped us to create an item in the same REQ. Unfortunately, I can't remember where I found it so I couldn't really explain how it works. It's not pretty, but at least you don't have to delete a REQ.
function addItem() {
// add item to current request
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request, 'sys_id of item', 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);
// update/add values to variables on item
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.addQuery('request', current.request);
grReqItem.addQuery('cat_item','sys_id of item');
grReqItem.query();
if(grReqItem.next()) {
grReqItem.variables.some_true_false_var = true;
grReqItem.variables.some_other_var = 'Yes';
grReqItem.parent = current.sys_id;
grReqItem.variables.comments = "Add any comments here.";
grReqItem.update();
}
}
Also, have you tried adding the variables needed to both the current item and the item being added? If you have the workflow from Item A create Item B, making sure you set the "parent" of Item B as the sys_id of Item A, you could have Item B refer back to Item A by using the "parent" field and updating the variables that way (query for Item A using "parent" and then set the variables).
We do something like this in some other workflow, but this might be more complicated than necessary.
Anyway, hope some of this helps!
Barb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 10:43 AM
Does anyone know how I can get this to update a specific RITM?
Say I have a field in in a from in the service catalog asking for the Request Item # - and then I want the information filled out to be added to that already existing RITM?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 10:52 AM
Hi Lisa,
You shouldn't need to use the GlideappCalculationHelper to update an existing RITM. The solution to what you want to do would actually be simpler.
You would pretty much just take the 2nd part of the code in the first post where the RITM is being updated.
In the query, you would query for the RITM you want to update using the value of the reference field.
You could use a get, since it's one record. It would be something like:
var gr = new GlideRecord('sc_req_item');
gr.get(fieldName); //name of reference field
gr.variables.variableName = current.variable.variableName //for each variable or field you want to update.
gr.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2017 07:17 AM
Thank you Thomas!
I think I am missing something though -
I want the fields in this form:
to be displayed on this form when submitted:
Similarly to the Variables that are already listed... is that possible? I am not seeing how to get them to display. OR if you have any suggestion on another way to achieve this...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2017 07:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2017 10:21 AM
if you go into the item from the service catalog does it lay it out correctly?
sounds like you may have the order messed up in the item itself.... also if not please post what version you are on and any other information.. drawing the RITM form variable section is based on the item itself from maintain items.