Automatically Create RITM using Workflow (CARTJS)

anvitha ash
Tera Contributor

Hi, 

 

We have a catalog item (lets say name as: "Assets")  with 2 variables

1. requested for

2. category  (type: select box) with 2 choices

  •         choice1: AWS
  •         choice2: Hardware

when "AWS" is selected it should trigger a catalog item(called AWS Request) and autofill the values from Asset from to AWS Request form and generate a RITM automatically using workflow

 

var ccart = new sn_sc.CartJS();

var newItem = ccart.addToCart({
"sysparm_id": "33af1a38dbffccd054ce3e5f9d9619b3", // AWS catalog item sys_id
"variables": {
"v_new_hire_name": "jdaf1a74dbfrnhdo8fce6t2f9d60h6yu", // Sys_id of user(static value), i need dynamic value here
}
});

var checkoutInfo = ccart.checkoutCart();

 

 

with static value it is working fine as expected, but requirement is requested for should be dynamic and it should be populated from "Asset catalog item"

1 ACCEPTED SOLUTION

Try below:

"v_new_hire_name": current.requested_for.toString(), 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

4 REPLIES 4

Anil Lande
Kilo Patron

Hi,

I believe you need to change it like below in your workflow script.

if(current.variables.category == 'aws') { // use name of variable and choice value as per your configuration
var ccart = new sn_sc.CartJS();
var newItem = ccart.addToCart({
"sysparm_id": "33af1a38dbffccd054ce3e5f9d9619b3", // AWS catalog item sys_id
"variables": {
"v_new_hire_name": current.variables.requested_for, // use correct name of requested for variable
}
});
var checkoutInfo = ccart.checkoutCart();
}

 

Replace correct variable names and choice values in above script.

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi @Anil Lande ,

 

I tried with 

"v_new_hire_name": current.variables.requested_for, // replaced with my variables

 

 

It still not working...filed is still getting empty

Try below:

"v_new_hire_name": current.requested_for.toString(), 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

@Anil Lande ,

 

Thanks now it's working