Highlighted
Established Member.. oldweasel
Established Member..
121 views

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: 

if(selected_modality=='Pickup');

 

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?

0 Likes
2 Replies
Outstanding Contributor.. JHF Remmelzwaal Outstanding Contributor..
Outstanding Contributor..

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

selected_modality=='Pickup'

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:

LR.getParam('p_Modality_Type')=='Pickup'

P.S.

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.

Success

0 Likes
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Re: Truclient - How to use variable results in "If" block conditionals??

Hi, you should use it like:

clipboard_image_0.png

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.