Script Cannot retrieve requested item variable

johnfeist
Mega Sage
Mega Sage

I know that this makes no sense, but it's happening.

 

I have a catalog item with a handful of variables plus a few variable sets.  In the workflow scripting I have a few lines that look like this:

 

var theBusiness = current.variables.what_business;
workflow.info("theBusiness " + theBusiness);
 
When that executes, theBusiness displays as undefined. That happens when I try to get the
value for any of the variables defined on this item. However if I execute the same for a
variable from a variable set, I get the correct value.
 
I have code like the above that runs correctly in any number of scripts, workflows, etc.
 
It doesn't matter if I try to retrieve the value in the workflow or just in a little test
script. If I go the route of querying sc_item_optiom_mtom and then go into the values in
sc_item_option I get what I need.
 
Do you have any idea why I'm only seeing this behavior for one item?
 
TIA for any insights you can provide,
 
:{)

 

 

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster
6 REPLIES 6

Shivalika
Mega Sage

Hello @johnfeist 

 

What type of field is this ? 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

 

Hi Shivalika, it's a string that is listed in a select box.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Brad Bowman
Kilo Patron
Kilo Patron

Have you logged the current user to confirm the user that the script is executing as?  Is this Catalog Item (and the variables) in the same scope as others? Have you tried testing with a display Business Rule on the sc_req_item table on a record where you can see the variable and value on the form?

Hi Brad,

 

The user is me and I have full admin rights.  Everything is in Global scope.  I can see the values on the sc_req_item display of that request no problem.  Having done a little debugging on the script, I'm able to get the value that I need by going through sc_item_option_mtom and sc_item_option.  While not ideal, it works.

 

:{)

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster