AnsweredAssumed Answered

Javascript API popup functions return value is unclear

Question asked by MollyKFoley on Sep 4, 2018
Latest reply on Sep 4, 2018 by MollyKFoley

I'm creating a custom pop-up where I send the attribute table value into a function to reformat it. It's called like so:


var herbicide = '${Herbicide1:herbName}'


It then enters the function like this (it has many more cases than what's shown):

herbName = function(value){
   herb = '';
       case null:
           herb = 'None';
       case 1:
           herb = '2,4-D';
   return herb;


The 'return herb' line should return the new value and I thought that the 'herbicide' variable would be set equal to whatever was returned, but that does not appear to be the case if I actually try to print it's value. When I print it:

>>> console.log(herbicide);

>>> ${Herbicide1:herbName}


This is making it really hard to do conditional statements on the variable. For instance, if herbicide is set to 'None' then I don't want it to show up in the popup, but using this statement:

if (herbicide == 'None'){
    //do something

It will never evaluate true because unfortunately, no matter what value was returned from the function, the value being tested against is always the string '${Herbicide1:herbName}'


What's weird to me is that you can't see the value by printing it to the console, yet I know my functions are returning the correct values because it prints them correctly to a popup. I can't test the value I need to test... what can I do to fix that?