Help with Tag Expression

Hello!

I have a box that I color it red depending of the value of a tag. However I need it to be dependent of 2 tags.

Let me show you:

As you may see, the tag is now set to "true".

I have another tag that is identical to the above one. I'm trying this:

But for some reason I'm getting a configuration error.

Any idea what I'm doing wrong or what could do to fix it?

I haven't show it, but I will add a map transform that returns the corresponding color dependign on the result of the expression.

I just noticed that I put {./AfarviEmbeddedView.props.params.path}+"/Connected" 2 times instead of the other name. However, it stil doesn't work.

I promise the other tag works correctly.

That expression is only to construct the tag path, which then return the value of the tag.

You would need an expression, using the 2 tag values in the expression. There are many ways to achieve that, e.g. read your 2 tags into custom properties and then compare them.

Another option is to use tag("path1")||tag("path2") in an expression

Invalid tag path :frowning:

I'll add that the path is a parameter that I write in another component.

Something like this: [UNS]Plant/Neo/Systems/AGVSystem/Connection01
image

You are doing a tag binding, with the expression constructing the path.

Use an actual expression binding:


Like Deon said, you're currently using an expression to build the tag binding. You want the expression binding below.

Thanks!

Thanks!

This is extremely bad advice. The tag() expression function has numerous problems in UI bindings. Move the indirection into separate bindings on custom properties, then use an expression binding that references those two properties.

Use the tag() expression function only in expression tags, not in any other kind of binding.

3 Likes

@pturmel I ended up doing this:

I don't quite get why I would have to do it in custom properites. What does it change?

The performance of tag() leaves a lot to be desired. It will perform better if you use a custom property with an idirect tag binding for each tag, then bind the stroke to an expression that uses those two custom properties.

4 Likes

Expression bindings are synchronous. They must return a value when executed. The tag() expression function stalls when first called, waiting for a reply to its subscription request. If you scatter tag() expression functions through a bunch of bindings in a commonly-used view, you will have stalls on those views that are the sum of all the stalls in the bindings.

Tag bindings don't stall. They simply don't produce any property assignment at all until the subscription answers, and only produce future assignments when the subscription delivers changes.

3 Likes