- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 07:37 AM - edited ‎01-09-2024 07:42 AM
Hi,
I have created a record producer which creates multiple catalog items. I have used the cart functionality. In one of my catalog items there is MRVS, I want to set one of the variable values for that MRVS. That variable is List collector and while creating the record I am passing the sys id. But the value is not getting populated for that variable in MRVS. Basically, I am not able to set variable value for MRVS through record producer script. I tried 3 ways highlighted as red but no success.
Everything is working fine for other variables other than MRVS variables. Can anyone guide me how I can achieve it.
Here is my code which I have written in script of Record Producer:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 12:32 PM
You cannot set the MRVS value via the Cart API, but you can update the RITM after it's created, and you need to properly concatenate the string when inserting the producer value, and that needs to be inside of quotes which must be escaped from the encapsulating string quotes:
var item = '';
var cartId1 = GlideGuid.generate(null);
var cart1 = new Cart(cartId1);
item = cart1.addItem('sys_id', 1); //passed sys id of cat item
cart1.setVariable(item, 'requested_for', producer.requested_for);
cart1.setVariable(item, 'action_required', "Modify");
cart1.setVariable(item, 'modify_detail', "Group members");
cart1.setVariable(item, 'justification', producer.business_justification);
var rc = cart1.placeOrder();
//query RITM and set the MRVS value
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', rc.sys_id);
ritm.query();
if (ritm.next()) {
ritm.variables.members_added = "[{\"id\":\"" + producer.requested_for + "\"}]";
ritm.setWorkflow(false);
ritm.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 12:32 PM
You cannot set the MRVS value via the Cart API, but you can update the RITM after it's created, and you need to properly concatenate the string when inserting the producer value, and that needs to be inside of quotes which must be escaped from the encapsulating string quotes:
var item = '';
var cartId1 = GlideGuid.generate(null);
var cart1 = new Cart(cartId1);
item = cart1.addItem('sys_id', 1); //passed sys id of cat item
cart1.setVariable(item, 'requested_for', producer.requested_for);
cart1.setVariable(item, 'action_required', "Modify");
cart1.setVariable(item, 'modify_detail', "Group members");
cart1.setVariable(item, 'justification', producer.business_justification);
var rc = cart1.placeOrder();
//query RITM and set the MRVS value
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', rc.sys_id);
ritm.query();
if (ritm.next()) {
ritm.variables.members_added = "[{\"id\":\"" + producer.requested_for + "\"}]";
ritm.setWorkflow(false);
ritm.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2024 01:12 AM
Thanks @Brad Bowman . It worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2024 06:35 AM
You are welcome!