Trigger a catalog item via Record producer. Review my code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2024 08:35 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2024 08:47 AM
Use better/unique variable names instead of potentially-reserved / keywords 'from' and 'to'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2024 08:59 AM
Hi @Dash2 ,
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!
Rampriya S