- 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
05-30-2017 02:18 PM
Can someone please help on this?
I am trying to understand GlideappCalculationHelper and tried following example. After this executed in addition to adding a new item i requested it's o duplicating existing request item in that request.
//Run your script here
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.get('sys_id','22e814c00f3632001354943be1050e4c');
grReqItem.query();
if(grReqItem.next()){
workflow.info('fetched record is {0} ' , grReqItem.getValue('sys_id'));
workflow.info('Parent record is {0} number {1} ' , [grReqItem.request , grReqItem.request.number]);
}
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(grReqItem.request, 'f08272580f2632001354943be1050e59', 1); // request,cat item, 1 is the qty
reqHelper.rebalanceRequest(current.request);
grReqItem.request has one request item before running this script. After running it has three request items. Wondering why it's duplicating existing item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2017 08:48 AM
Hi Barbara - I am trying to use this in a workflow running on the request table on geneva and unfortunately its not working. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 06:22 PM
Hi Barbara,
I have tried GlideappCalculationHelper() new req item is generated and variables also added,thank you .
But problem is Prices are giving wrong values.how to solve this issue please help me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2020 12:51 PM
This will not work if you are adding same catalog item multiple times using add to cart functionality..
Use "Add to Cart" and submit a request with 10-20 of the same item.. I doesn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 01:44 AM
Thank you so much barbsies, so far this is the only code in the forum that works up to updating the variables of created multiple RITM in the existing REQ..