UI Policy if Condition (in Script)

Gal Katz
Kilo Sage

I have a UI ACTION button that I want to Hide. I am getting an answer from Script-Include of TRUE/FALSE which is stored in 'response' Variable.

But for some reason the script enters the first if conditions (gets to the if with 'entered Show command' InfoMessage and the show() command) regardless of the value I get in response. does anyone have a clue on why this is happening or how to fix it?

Screenshot_20221207_042444.png

 

1 ACCEPTED SOLUTION

Mike_R
Kilo Patron
Kilo Patron

maybe it's getting passed as a string and not a Boolean.

Try

if (response == 'true'){ 

View solution in original post

3 REPLIES 3

Mike_R
Kilo Patron
Kilo Patron

maybe it's getting passed as a string and not a Boolean.

Try

if (response == 'true'){ 

Thanks you saved the day!

Paul Curwen
Giga Sage

Try replacing lines 7,8,9 with this:

 

function getResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer) {

 

The reason your code isn't working is as follows: 

 

Here "response" is an XML document which contains an attribute "answer" and the value returned from the function bound with the answer attribute.

 

So response.responseXML.documentElement.getAttribute("answer") gives us the value returned from the script includes function.

 

Please mark as Helpful/Correct if this helps solve your issue

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul