
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2021 02:50 AM
Hi Everyone,
I'm using the cart API as follows to create some orders automatically (inside some scripted REST API)
var cartId = GlideGuid.generate(null); |
However it's not working, the order is created with an empty multi row variable set, trying to supply a stringified JSON is not working, how can I proceed?
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2021 03:08 AM
you cannot set MRVS using Cart API.
You can update the variable post RITM creation
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('someCatalogItemId');
//fill in the variables on the request item form
cart.setVariable(item, "asset", "00a96c0d3790200044e0bfc8bcbe5dc3");
cart.setVariable(item, "multiple_choice", "Phoenix");
var rc = cart.placeOrder();
// query RITM and update that
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', rc.sys_id);
ritm.query();
if(ritm.next()){
ritm.variables.someMultiRowVariableSetName = "[{\"plugin_name\":\"plugin 1\"},{\"plugin_name\":\"plugin 2\"}]";
ritm.setWorkflow(false);
ritm.update();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2021 02:54 AM
Hi,
Check this
https://community.servicenow.com/community?id=community_article&sys_id=4b54ab561bfa445cada243f6fe4bcbeb
https://community.servicenow.com/community?id=community_question&sys_id=5d28d390db272300fb115583ca961920
http://rubenferrero.com/servicenow/multi-row-variable-set-form-communication/
Thank you
Prasad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2021 02:58 AM
Thanks for your support, but none of these threads addressing my problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2021 03:08 AM
you cannot set MRVS using Cart API.
You can update the variable post RITM creation
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('someCatalogItemId');
//fill in the variables on the request item form
cart.setVariable(item, "asset", "00a96c0d3790200044e0bfc8bcbe5dc3");
cart.setVariable(item, "multiple_choice", "Phoenix");
var rc = cart.placeOrder();
// query RITM and update that
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', rc.sys_id);
ritm.query();
if(ritm.next()){
ritm.variables.someMultiRowVariableSetName = "[{\"plugin_name\":\"plugin 1\"},{\"plugin_name\":\"plugin 2\"}]";
ritm.setWorkflow(false);
ritm.update();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 01:07 PM
This is wrong, you most certainly can update a multi-row variable set via CartJS. I do it all the time.
var updateItemResponse = new sn_sc.CartJS("Custom Cart Name").updateItem({
"sysparm_id": catalogItemID,
"sysparm_quantity": "1",
"variables": {
"action": inputs.formData.action,
"user": inputs.formData.user,
"assets_table": inputs.formData.assets_table
}
}, cartItem.cartItemID);
The inputs.formData.assets_table variable would need to be structured like a JSON object.
[
{
"asset_id": "2b86a1ca1bdc8950e4eb0d0fdc4bcb75"
}
]