Bulk Create Request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2020 11:44 PM
Hello,
We are required to bulk create RITMs from values in an excel file. Currently, I already have a source table and transform map with the ff onBefore script:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
createRequest();
function createRequest() {
var cart = new Cart();
// add in cart, substitute your cat item sys_id
var item = cart.addItem('xxxxxxxxxx'); //catalog item sys_id
//Set Variables in your Cart Item
cart.setVariable(item, 'requested_for', gr.u_requested_for);
cart.setVariable(item, 'employee_id', gr.u_employee_id);
cart.setVariable(item, 'department', gr.u_department);
var rc = cart.placeOrder();
}
})(source, map, log, target);
However, it's not running as expected. I've tried setting the target table to: both Request [sc_request] and Request Item [sc_req_item] but I only get blank REQs and RITMs.
I've already seen these and also based the script from them:
- Request Item Workflow Not Starting when using Cart API and Email Inbound Action for Guest user
- Is there an automated way to create bulk requests?
Am I missing something or is there a different way to bulk create requests that would also trigger the workflow accordingly?
Thank you in advance!
Alison

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2020 11:47 PM
cart.setVariable(item, 'requested_for', gr.u_requested_for); // Where is gr coming from? itz not defined anywhere. it shud be returning undefined
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2020 12:45 AM
Hello Harish,
Thanks for pointing that out! Didn't notice, sorry about that.
I updated it to below script but it's still creating blank requests:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
createRequest();
function createRequest() {
var cart = new Cart();
// add in cart, substitute your cat item sys_id
var item = cart.addItem('xxxxxxxxxx'); //catalog item sys_id
//Set Variables in your Cart Item
cart.setVariable(item, 'requested_for', source.u_requested_for);
cart.setVariable(item, 'employee_id', source.u_employee_id);
cart.setVariable(item, 'department', source.u_department);
var rc = cart.placeOrder();
}
})(source, map, log, target);
Regards,
Alison