- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 03:27 AM
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"
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 05:05 AM
Try below:
"v_new_hire_name": current.requested_for.toString(),
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 04:47 AM
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.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 05:00 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 05:05 AM
Try below:
"v_new_hire_name": current.requested_for.toString(),
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 03:46 AM