Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Unique GuidID for the CartJS API var cart = new sn_sc.CartJS(gs.generateGUID()); is not working.

Girisha
Tera Contributor

ServiceNow suggested using a Unique GuidID for the CartJS API "

var cart = new sn_sc.CartJS(gs.generateGUID());" to address a duplicate RITM issue. However, after implementing this solution, only the Request is being created, and the RITM is not generating. Any assistance on this matter would be greatly appreciated. Thank you!

 

 

        var cartid = "cart_" + gs.generateGUID();
        var cart = new sn_sc.CartJS(cartid);

        var request = {
            'sysparm_id': 'e8747cf17c23150049d0205f9e6396fb',
            'sysparm_quantity': '1',
            'variables': {
                'email': email.body_html,
                'offBoardingComments': 'received from: ' + email.origemail,
                'name': usersysID,
                'manager': manager,
                'last_day': email.body.end_date,
                'end_date': email.body.end_date,
                'req_via_email': true
            }
        };


        cart.setRequestedFor(usersysID);

        var cartDetails = cart.orderNow(request);
3 REPLIES 3

Shruti
Giga Sage
Giga Sage

Hi

Try to Replace the last line var cartDetails = cart.orderNow(request); with 

 
var cartVals = cart.addToCart(request);
var checkoutVals = cart.checkoutCart();

Brad Bowman
Kilo Patron
Kilo Patron

Does this exact script work, albeit with a duplicate RITM issue, as-is with the exception of the first line, and with the second being:

var cart = new sn_sc.CartJS();

Do the system logs at the time of running this code indicate anything useful?  As shown, usersysID and manager are undefined...

 

 

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Girisha 

I don't think duplicate RITM issue is because of your script.

Since ServiceNow suggested this change didn't they test it out?

what debugging did you do from your side?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader