Hi community,
I want to use choose instead of nested if to display status text in different colors.
I tried this expression and it throws this error A grid column [label=“Status”] has encountered an error. Expression evaluation error at function 'choose' [line 58]: Invalid index (1) for list: valid range is empty.
choose(wherecontains({fv!row[aRecord.status]}, cons!STATUSES)[1],"SECONDARY", "SECONDARY", "SECONDARY", "POSITIVE", "NEGATIVE", "STANDARD")
what am i doing wrong here?
Kind Regards,
Erik
Discussion posts and replies are publicly visible
Agree with the other posts here. This is essentially how I would typically implement, it also allows you to set a default with index() in the off chance you get a status you don't expect, an error will not be generated:
a!localVariables( local!index: index(wherecontains({fv!row[aRecord.status]},cons!STATUSES),1,1), choose(local!index,"SECONDARY", "SECONDARY", "SECONDARY", "POSITIVE", "NEGATIVE", "STANDARD") )
Thanks you all for the replies, I will try and report back later.
Wouldn't it be easier to use displayvalue() here. Something like this should do it
displayvalue( fv!row[aRecord.status], cons!STATUSES, {"SECONDARY", "SECONDARY", "SECONDARY", "POSITIVE", "NEGATIVE", "STANDARD"}, "STANDARD" )
thank you all for your answers. turned out to be the wrong constant because of two with almost identical names. Did also implement the local var, and the index default value. @Stefan will give your displayvalue solution a try as well.