Creating multiple Request Items based on number selected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2013 03:16 AM
Hi
I have a UI Action that creates an event, script action then calls a script include to add a Catalog item and fill in various variables then places the order to create 1 Request and 1 Request Item automatically. This is all fine and works as it should.
I'm struggling with the following - On the UI Action table there is a quantity field, if this quantity is say 5, I want it to create 5 RITMS for the same catalog item, same field data and variables. Ideally they would sit under the 1 Request, however it could be that we have 5 separate requests with 1 RITM under each, this is how it's done currently but manually using the order guide.
Has anyone done anything similar or have an hints how I may achieve this.
Thanks
Dave
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2013 02:50 AM
It's Friday, I think I'm misunderstanding your solution.
I have a field with a number, based on that number I want to create that number of RITM's.
I assume i is my number?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2013 03:10 AM
50 is your number, and initialize i to 0...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2013 06:28 AM
Definitely a friday thing no idea why it wasn't working, it is now. Thanks for your help.
var quantity = parseInt(rec.u_quantity,10);
var i = 0;
while (i < quantity) {
var item = cart.addItem('07b8a581b0401100ce6b89bb520f5e10', 1);
cart.setVariable(item, 'requested_for', rec.u_requested_for);
cart.setVariable(item, 'u_required_date', rec.due_date);
cart.setVariable(item, 'u_quantity', rec.u_quantity);
i++;
}
var rc = cart.placeOrder();
gs.log("Request Logged " + rc.number);
};