Create draft cart for other user

Peter Xiang
Tera Expert

Hi,

I want to create a draft cart for other user, so I used CartJS API. But after I run this script, this record only show admin's request list, I want this record display under employ B's request list. How can I resolve this?

 

var cart = new sn_sc.CartJS('draft_items');
var item = {
    'sysparm_name': grRecord.getValue("number") + ' has been returned, this record is automatically generated',
    'sysparm_id': grRecord.hr_service.producer + "",
    'sysparm_quantity': '1',
    'variables': variablesObj
};

cart.setRequestedFor(requestedFor); //this is sys_id of employee B
var cartDetails = cart.addToCart(item);

PeterXiang_0-1752822824319.png

PeterXiang_1-1752822856224.png

 

 

2 REPLIES 2

Armando Cardos1
Tera Expert

Hi @Peter Xiang ,

 

For me, I added the user sys_id on:

var cart = new sn_sc.CartJS('draft_items',[USER_SYS_ID]);
 
Let me know if this works for you too.

Hi @Armando Cardos1 ,

Thanks for your update, this draft item display on my draft list, but when I click the draft record, here is an error message "You are either not authorized or record is not valid". Do I miss some actions?

PeterXiang_0-1753264115839.pngPeterXiang_1-1753264123860.png