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

How are you getting the sys_id? I'm pretty sure if you just get the value of the source variable, that is the sys_id. Or are you trying another way?

Eckhard
Tera Contributor

I get the sys_id with current.variables.[variable_name] and it is definitely there. I checked it with gs.warn. I saw the correct sys_id in the log.

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