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.

Trigger a catalog item via Record producer. Review my code

Dash2
ServiceNow Employee
ServiceNow Employee

Hello, community,

 

I'm trying to submit a catalog item via a record producer.

 

The code below works when I tested it on a background script but not with my record producer. When submitted via the RP, the requested item is generated, but the variables aren't being carried over from the producer to the catalog item.

 

var from = producer.from_stockroom;
var to = producer.to_stockroom;
var ser = producer.serial_number;

var cart = new sn_sc.CartJS();
var request = {
    'sysparm_id': '1b4aad57c394d294a8acde5bb0013124',
    'sysparm_quantity': '1',
    'variables': {
        'from_stockroom': from,
        'to_stockroom': to,
        'serial_number': ser
    }
};
var cartDetails = cart.orderNow(request);

@Ankur Bawiskar  

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

Use better/unique variable names instead of potentially-reserved / keywords 'from' and 'to'.

Rampriya-S
Kilo Sage
Kilo Sage

Hi @Dash2 ,

rampriya_S_1-1725638298014.png

 

Use the 'Map to field' and map the variable to the form field.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0787280

 

Please mark as helpful, if the solution is helpful!

 

Best,
Rampriya S