sn_sc.CartJS() doesn't work

Theodor
Tera Contributor

Dear community,

 

I'm struggling with my recent problem in that I can't use CartJS() properly for some reasons.

I'm trying to log some requests in a GlideRecord loop by this script:

var today = new GlideDate();
var keepMailbox = new GlideDate();
keepMailbox.addMonths(3);

var gr = new GlideRecord('sys_user');
gr.addQuery('u_expiration_date', today);
gr.query();

while(gr.next()){

var cart = sn_sc.CartJS();    
var request = {
'sysparm_id': '9b0f57e26c4670000fe4d2434fed192f',
'sysparm_quantity': '1',
'variables':{
'hr_end_employee_for_which_user': gr.getUniqueValue(),
'hr_end_employee_user_manager': gr.manager,
'hr_end_employee_user_location': gr.location,
'hr_end_ecid': gr.u_employee_central_id,
'hr_end_employee_is_user_leaving_bunge': 'Yes',
'hr_end_employee_end_date_time': new GlideDate(),
'hr_end_employee_time_sensitive': "No",
'hr_end_employee_notes_data_keep': 'Yes',
'hr_end_employee_keep_data_until': keepMailbox,
'hr_end_employee_notes_data_access_user': gr.manager,
'additional_notes_to_it': "Autotermination due to expiration of the account in AD"
    }
}
var cartDetails = cart.orderNow(request);
gs.info(cartDetails);
}
 
But unfortunately the output is Undefined, Undefined, Undefined. (The loop is working fine, it should be 3 records in that GlideRecord) but I'm not able to log the requests.
Theodor_0-1680518101528.png

 

 
I really don't know what's missing.
 
Thank you in advance for all your support,
Teodor
7 REPLIES 7

Theodor
Tera Contributor

Anybody that know a solution for this ?

lauri457
Tera Contributor

You need to create a new object from the CartJS class. The glidedates might need conversion too.

//var cart = sn_sc.CartJS();    
var cart = new sn_sc.CartJS();    

 

nunofilipehomem
Tera Contributor

There is a strange interaction between CartJS and variables called gr, so try replace the variable name you're using in the GlideRecord.