- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 07:34 AM
Dear all,
I have implemented a workflow logic attached to a catalog item to collect the variables of a requested item (I call it parent) and use them to open a new request/requested item (child) and "copy" the variables to the new REQITM.
This works perfect with sn_sc.CartJS and I can fill the variables in the new child REQITM as long as they are standard text.
But now I have a reference field in my parent and also in my child.
I can pick the sys_id of the selected value from the reference field in the parent.
But the reference in the child stays empty.
I create the variable set as you see below:
// my_switch is the reference variable of the parent REQITM and has the sys_id
// which_switch_child is the refernce variable in the child REQITM
var cart = new sn_sc.CartJS();
cart.empty();
var my_variables = {"var1":my_variable1,"var2":my_variable2,"which_switch_child":my_switch};
var request = {
'sysparm_id': cat_item,
'sysparm_quantity': quantity,
'sysparm_requested_for': myID,
'variables': my_variables
};
cart.addToCart(request);
var checkoutInfo = cart.checkoutCart();
...
Do you have an idea?
Many thanks
Best regards
Eckhard
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 11:51 AM
From the information you've provided, there shouldn't be an issue. I would triple check spelling/spacing on the variable name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 07:41 AM
Do both reference fields have the same backend name and are they pointing to the same table? Is there any difference in the configuration of the variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 09:01 AM
Hi,
both are pointing to the same reference table cmdb_ci_ip_switch. The name of the variables is different which should not have an impact, because the target variable name is defined in the "my_variables" json string ... or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 09:30 AM
In that my_variables, are you explicitly setting the attribute for the switch to the name of the target variable with the value from the source variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 10:49 AM
Yes,correct.