- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 10:05 AM
Hi,
I am trying to generate a request/task using a business rule based on predefined values from another form. I am having issues setting the "requested_for" value. Everything seems to work fine, it creates the request, request item, and task. But the only field that is not properly being set is the "requested for" field. For some reason it always sets it to the person executing the script, when it should be setting it to "current.u_affected_user". I even tried setting the cart.requested_for value, but it still doesn't work.
Also, in the workflow for this catalog item there I do set the requested_for variable based on the variables in the form so it should take that value...
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem(workOrderSysID);
cart.requested_for = current.u_affected_user;
cart.setVariable(item, 'short_description', short_desc);
var full_description = 'This IT Internal Request was automatically created from Call Record ' + current.number;
cart.setVariable(item, 'description', full_description);
cart.setVariable(item, 'assignment_group', current.u_assignment_group);
cart.setVariable(item, 'requested_for', current.u_affected_user);
var rc = cart.placeOrder();
rc.u_call = current.sys_id; //add a reference to the initial call into sc_request
rc.update();
Any help would be much appreciated.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 11:16 AM
Thanks Pradeep, I actually ended up using this code instead:
var rc = cart.placeOrder();
rc.u_call = current.sys_id; //add a reference to the initial call into sc_request
rc.requested_for = current.u_affected_user;
rc.short_description = short_desc;
rc.update();
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 10:15 AM
Hi Tyson,
Can you please refer my solution here and check if that resolves your issue.
how to set requested for and opened by in a request using the cart API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 11:16 AM
Thanks Pradeep, I actually ended up using this code instead:
var rc = cart.placeOrder();
rc.u_call = current.sys_id; //add a reference to the initial call into sc_request
rc.requested_for = current.u_affected_user;
rc.short_description = short_desc;
rc.update();
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 11:19 AM
Thanks Tyson for the update.
Glad you got it figured out