Open REQITM with sn_sc.CartJS not possible with reference fields

Eckhard
Tera Contributor

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

 

1 ACCEPTED SOLUTION

From the information you've provided, there shouldn't be an issue. I would triple check spelling/spacing on the variable name.

View solution in original post

7 REPLIES 7

Kristen Ankeny
Kilo Sage

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?

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?

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?

Yes,correct.