[IGN-6833] Scripting and expressions consider all view params to be strings

I am wanting to pass a boolean value to a popup view param, like so..

I cannot for the life of me figure out what to put in, nothing works.
I've tried, 'false', 'False', 0, '{false}', '{False}'

The only way I can get this to work is making another view prop called 'permafalse' and passing that in, seems like a dirty way to do this...

What is the correct way to do this?


Just open the popup through scripting. Or you'll have to use the 2nd option.

1 Like

I just tried and indeed, it seems you can't pass booleans...

I'd do this instead:

Make a custom property, bound to the param, where you check if its value is "true", or "True", or 1, or whatever you want to use as boolean values.

I wonder if this is because of the mismatch between json and python

Doesnt look like it even gets converted to json, its just a string literal or if inbetween {} its trying to get a path

Here are the reasons your previous attempts failed:
'false': String (always evaluates as true)
'False': String, but now it's upper-case.
0: This is a number, but in theory it should have evaluated as false unless you have a direct comparison*
'{false}': This is a String, with brackets around the word "false".
'{False}': This is a String, with brackets around the word "False", where the "F" has been capitalized.

What you want:
false, with no quotes, not brackets, and the "f" is lower-case. Make sure to hit Enter when you're done typing false so that the value is properly committed to the field; a common issue when applying values in these fields is that the user does not properly commit the value.

*The 0 value would fail later evaluation if you have comparisons like this: {view.params.foo} = "true" or even {view.params.foo} = true because you're doing a direct equality comparison between a numeric value and either a string or boolean value. If you're passing 0/1, you have to allow for them to be evaluated as a boolean value. Supposing a foo param value of 0, you can use the numeric value as a boolean flag as long as you allow code to treat it as such.

if self.view.params.foo:  # 0 will be evaluated as false-y here.
    # do something
1 Like

Still getting a unicode

Doesn't work.


'custom' is bound to 'view.custom.foo'
'param' is bound to 'view.params.foo'

'view.params.foo' 'view.custom.foo' has this expression binding:
{view.params.foo} = "true"

That's correct: {view.params.foo} will evaluate as true, but then you have it bound to a comparison against a string value; since true is not equal to "true", it is becoming false. Remove your binding on view.params.foo.

I mistyped, the binding is on {view.custom.foo}

{view.params.foo} does not evaluate as true, but as "true", even though the parameter passed was a boolean.

Actually, anything you pass to the popup action is interpreted as unicode:



Hmmm. I am seeing some odd behavior as I dive deeper into this. On my end, the value I'm passing is correctly being evaluated as a boolean value, and yet reporting of the type of the value does indeed report as Unicode. I'll look into this a bit more and report back later.

1 Like

This is a bug on our end. I'll spare you the technical details, but we have an open internal ticket to get it fixed. It's a fairly low priority because it's been this way for... forever, and bindings against these values still work. The primary impact is that direct references (scripting and expressions) view the params as strings.

Thank you everyone for your help with this. Unfortunately, the best solution for my particular use case has been the one I was already using, of simply creating two props, one called peramatrue, the other called permafalse and passing that in. The popup is for either creating or updating a database and is called by 2 different buttons, so this is adequate.

There are other places in my project that I've needed to do this. Simply evaluating the property as a boolean was failing. Thank you!