Truclient - How to use variable results in "If" block conditionals??
Trying to get the "drag and drop" IF statement block to work and not having much luck with the "false" condition (i.e. - every check is being considered "True")
As part of my script prior to the IF block I'm populating a variable based on a parameter:
var selected_modality = LR.getParam('p_Modality_Type');
I want my IF / ELSE statement to be able to act based on if the content of the variable matches a given modality type, and have the following JS code in my IF block condition statement:
What I'm finding is that regardless of what is in the selected_modality variable the statement is always being treated as TRUE by the block (i.e. the "Else" condition never fires).
Using breakpoints I've confirmed that the selected_modality value is getting set correctly, how do I get the Condition to be read as FALSE if the condition is indeed FALSE?
Re: Truclient - How to use variable results in "If" block conditionals??
You stated: "have the following JS code in my IF block condition statement: " and then your code follows. An TruClient IF-block needs only a condition so you might put in only
But when you declare the variable in another JS-block, this variable is not available in your IF-block. You need to put it into the right scope (Out of my head) use Global.variable_name to let a variable live outside a JS-block in TruClient.
You might also use in the IF-block condition:
Take some time to read about JS scope of variables in TruClient. It took me also some time to understand.There are multiple scopes involved and some TruClient JS blocks need different scopes.
Reward community members who take time to respond and help.