Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Creating multiple Request Items based on number selected

dave_m13
Kilo Contributor

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

7 REPLIES 7

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?


50 is your number, and initialize i to 0...


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);
};