Submit catalog request from Transform Script

Fred Abram III
Tera Expert

Hi guys,

 

I am trying to create new Service Catalog Request when I upload records from my import set. At any given time the import set can contain 50+ records and I need a record for each. I have created a Transform Script that will use API to populate data, however, I am not getting the desired results. Please take a look at my code and let me know if I am missing anything or if it is even possible.

FredAbramIII_0-1673560637877.png

 

1 ACCEPTED SOLUTION

Fred Abram III
Tera Expert

I got it to work using the following format

FredAbramIII_0-1678235268225.png

 

View solution in original post

6 REPLIES 6

Tony Chatfield1
Kilo Patron

Hi, a partial screenshot doesn't allow for much of a review\assessment.
What are the results of your debugging, is the transform script triggered, are your target fields populated as you expected? Perhaps add some logging\debugging so you can see what is\isn't happening, this will help you work through your problem.

Hello,

I have placed log statements into my code and can see them when I check the logs so I know that the transform script at least runs, however, I do not see any Service Catalog records getting created which is what I am trying to accomplish.

I have tried changing the When to "onAfter" instead of "onBefore" and have tested using "source" instead of "target" and am not getting records created. 

I have attached a full screenshot of my current transform script for better review\assessment:

FredAbramIII_0-1673972624334.png

 

ricker
Tera Guru

@Fred Abram III,

You need to define your JSON object first then add it to your cart....oh I see you're doing that with the newItem (more confusing to read that way) declaration but I don't see it being called....doesn't look like newItem or checkoutInfo are being triggered.

 

var item =
{
'sysparm_id': 'sys_id_goes_here',
'sysparm_quantity': '1',
'variables':{//example copied from docs page
   'carrier': 'at_and_t_mobility',
   'data_plan': '500MB',
   'duration': 'eighteen_months',
   'color': 'slate',
   'storage': 'sixtyfour' 
}};
var cartDetails = cart.addToCart(item);//now you can add the item to the cart

 

I ended up not using the API method. I now am able to submit the Catalog Item but not all the variables are passing to the RITM. Any suggestions?

 

FredAbramIII_0-1675358963659.png