CartJS suddenly not working in prod.

Brian Lancaster
Tera Sage

I have an inbound action that creates a request. For some reason the emails into dev work fine but into prod they stop request get added to the cart but never gets ordered. The code is below, there is no difference between dev and prod when it comes to the code. Any idea on what might be causing this?

(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

    // Implement email action here
	var domain = getStringBetween(email.body_text, 'for ', ' expires');
	
	var cart = new sn_sc.CartJS();
    var item = {
        'sysparm_id': '1b1f3be7dbd2a55070c91c7913961904',
        'sysparm_quantity': '1',
        'variables': {
            'domain': domain
        }
    };
    var cartDetails = cart.addToCart(item);
    var requestDetails = cart.submitOrder(item);

})(current, event, email, logger, classifier);

function getStringBetween(str, start, end) {
    result = str.match(new RegExp(start + "(.*)" + end));
    return result[1];
}
1 ACCEPTED SOLUTION

Brian Lancaster
Tera Sage

Figured it out, Not sure why this caused it to stop working. Since this is a item that only gets requested via a script I hid it so available for was set to only an admin could see it. This was not in dev. So I added another available for with the account that is in the associated with the inbound action. Basically it is the account with the email address that the email comes from. It is now working.

 

Since not 100% sure why it suddenly stopped working since this has been set this way for a long time.

View solution in original post

4 REPLIES 4

JohnnySnow
Kilo Sage

Anything in the logs?

Thanks
Johnny

Please mark this response as correct or helpful if it assisted you with your question.

Yes it has 

Root cause of JavaScriptException: com.glideapp.servicecatalog.exceptions.CartException
: com.glideapp.servicecatalog.exceptions.CartException: Your cart has item(s) no longer available. Please remove Certificate Renewal Request from cart to continue with the checkout.:

Interesting when I look at the item in the cart by impersonating the account I use in the inbound action. It looks like it would if you had deactivated the item. Meaning is grayed out and does not allow you to view or edit it the request like it normally would. The item is not inactive so I'm not sure what is going on. I verified that the sys_id is correct in my code for the active item.

Brian Lancaster
Tera Sage

Figured it out, Not sure why this caused it to stop working. Since this is a item that only gets requested via a script I hid it so available for was set to only an admin could see it. This was not in dev. So I added another available for with the account that is in the associated with the inbound action. Basically it is the account with the email address that the email comes from. It is now working.

 

Since not 100% sure why it suddenly stopped working since this has been set this way for a long time.