Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Read settings from a select field

ANSWERED

Hello, i have a probably very simple problem. I just want to select a specific value from a array:

 

Settings:

 

<Select
        label={`Battery`}
        settingsKey="battery"
        options={[
          {name:"pos01"},
          {name:"pos02"},
          {name:"pos03"}
        ]}
/>

 

In app:

 

  if (evt.data.key === "battery" && evt.data.newValue) {
    let myBatteryPos = util.stripQuotes(evt.data.newValue);
    console.log(myBatteryPos);
  }

 

console:

 

{selected:[0],values:[{name:pos01}]}

 

But i need only the value:

pos01

or pos2 or pos3

 

can someone help me. Many Thanks

Fitbit Ionic, Nokia 7 plus
Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Old:

let myBatteryPos = util.stripQuotes(evt.data.newValue);

New:

let myBatteryPos = JSON.parse(evt.data.newValue).values[0].name;

is working.

Fitbit Ionic, Nokia 7 plus

View best answer in original post

Best Answer
1 REPLY 1

Old:

let myBatteryPos = util.stripQuotes(evt.data.newValue);

New:

let myBatteryPos = JSON.parse(evt.data.newValue).values[0].name;

is working.

Fitbit Ionic, Nokia 7 plus
Best Answer