I have the need to display on a catalog item a list of details from records in a table, so I'm attempting to write a macro. In order to retrieve the records, I need to know the value of another variable on the form. In this example, I have a variable called "position" and I want to get its sys_id so that I can then find records in another table (u_required_item) and print the names and details on the form. I've tried quite a few things I found online, all to no success. This is the current script which is also not working. The printed output is just "Output: ()." So, it's obvious I'm not getting the value from the variable "position".

  
  
  Output: ($[jvar_position]).  

Kristen Ankeny正确答案作者:  在 2017-4-26 上午7:30

So, I think I've passed in what I need to do my coding. It's not ideal necessarily, there might be a cleaner way, but this is what I ended up doing (following the correct answer on this community post:  )

 

This is the macro:

  
  

 

On the form, I created two client scripts, one onLoad (because the form can inherit the value from an order guide) and one onChange of the Position field.

onLoad:function onLoad() {   setPosition(g_form.getValue('position'));} onChange:function onChange(control, oldValue, newValue, isLoading) {   if (isLoading || newValue == '') {      return;   }  setPosition(newValue);}

And now I'm finally getting the sys_id in a field (I'm going to hide it, the user doesn't need to see it, I just need it for scripting).

pastedImage_0.png