In an email inbound action using CartJS() to order from a specific user's cart.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 08:56 AM
I am building an inbound action to take an email from one of our automation tools and order a catalog item. in the email is the manager who I want to order the item from. However even if i add the setRequestedFor it still shows the email address ordered the item. Suggestions?
//get Employee Object
var employeeCorpID = email.body.corpid;
var employee = new GlideRecord('sys_user');
employee.get('user_name', employeeCorpID);
//get Manager Object
var managerCorpID = email.body.manager_corpid;
var manager = new GlideRecord('sys_user');
manager.get('user_name', managerCorpID);
//order Item
var cart = new sn_sc.CartJS();
var item = {
'sysparm_id': 'fd79407b1b95da10d40e2f05604bcb87',
'sysparm_quantity': '1',
'variables': {
'submitted_by': manager.sys_id.toString(),
'requested_for': employee.sys_id.toString(),
'title': employee.title.toString(),
'email': employee.email.toString(),
'location': employee.location.toString(),
'department': employee.department.getDisplayValue().toString(),
'phone': employee.phone.toString(),
'actions_needed': email.body_text
}
};
var cartDetails = cart.addToCart(item);
cart.setRequestedFor(manager.sys_id.toString());
var checkoutInfo = cart.checkoutCart();
var req_id = checkoutInfo.request_id;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 12:25 PM
It would be nice if the cartJS api could allow it like the old cart api could. I am just trying to catch it before communications go out.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 01:03 PM - edited 10-28-2024 01:04 PM
Emails are triggered by the event processor so it unlikely that the code will run so slowly that the event processor finishes before you code.
But I agree that it would be better to set the value as its created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 11:46 AM
Hi @Ilo Gassoway ,
Please refer below thread:
Please hit like and mark my response as correct if that helps.
Regards,
Sumanth Meda

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 12:25 PM
This doesn't seem to answer how to select a cart for a specific user.