Skip to main content
Solved

Extracting Value from Object Variable

  • May 30, 2023
  • 2 replies
  • 38 views

Forum|alt.badge.img+3

Probably a pretty simple script update here but I'm stumped... Everything just comes back as undefined rather than the value 1. 

 

Best answer by kuovonne

I believe @Sho’s explanation will work. 

The issue is that there are two things named inputVariable: the variable you assign the input.config() to, and the input variable that you created in the left panel of the editor. 

You are conflating the two. 
Things would be less confusing if you had only one thing named “inputVariable”. Even better would be to have nothing named “inputVariable”.

Name your input variable in the left panel “boatNumber”, then you can use


const inputConfig = input.config()

const boatNumber = inputConfig.boatNumber

There are other ways to do it, but whatever method you choose, it is best to have meaningful names. 

But also keep in mind that your boat number is actually a text string and not a number.

2 replies

Forum|alt.badge.img+21
  • Inspiring
  • May 30, 2023

I think you are mistaken
In this case. "inputVariable.inputVariable" will yield "1"


kuovonne
Forum|alt.badge.img+29
  • Brainy
  • Answer
  • May 31, 2023

I believe @Sho’s explanation will work. 

The issue is that there are two things named inputVariable: the variable you assign the input.config() to, and the input variable that you created in the left panel of the editor. 

You are conflating the two. 
Things would be less confusing if you had only one thing named “inputVariable”. Even better would be to have nothing named “inputVariable”.

Name your input variable in the left panel “boatNumber”, then you can use


const inputConfig = input.config()

const boatNumber = inputConfig.boatNumber

There are other ways to do it, but whatever method you choose, it is best to have meaningful names. 

But also keep in mind that your boat number is actually a text string and not a number.