How to get variable value inside IF ConditionHi all,
I am stucked in this IF Condition, where I need to get the variable value(color) based on another column value (:Fruit). It always return an empty variable color. Please help
Here's my sample code:
If( :Fruit == "Apple",
color= "Red"; Target = {50};,
:Fruit == "Grapes",
color= "Violet"; Target = {50};,
:Fruit == "Cherry",
color= "Red"; Target = {54};
);OtherScriptingRe: How to get variable value inside IF ConditionYou might consider the more specialized conditional function Match(). It is a nice alternative that is perhaps clearer as far as the intent and the result
Match( :Fruit,
"Apple",
color = "Red";
Target = {50};,
"Grapes",
color = "Violet";
Target = {50};,
"Cherry",
color = "Red";
Target = {54};
);Re: How to get variable value inside IF ConditionHi,
It is unclear what you are trying to do given the limited context. Is this part of a JSL script or a column Formula? If it is the latter, you need to specify what the expression returns as shown below:
If(
:Fruit == "Apple",
color = "Red";
Target = {50};,
:Fruit == "Grapes",
color = "Violet";
Target = {50};,
:Fruit == "Cherry",
color = "Red";
Target = {54};
);
color;
Also, are you sure that the column's content :Fruit matches precisely the values in your expression (i.e., no leading or trailing spaces)?
An example of the usage context for this expression would help figure out what may be going on.
Best,
TS