Indirect Tagging in Expression

I am trying to concatenate two string values by indirect method in scripting.

e.g. i have written this in expression section concat({[SBR]Seed Receiving/{view.params.AI}/Gross Value.value}, {[SBR]Seed Receiving/{view.params.AI}/Gross Unit.value})

where I have passed AI in the params section of my container

How can I do it any idea?

Try:

tag("[SBR]Seed Receiving/"+ {view.params.AI} + "/Gross Value")  +
tag("[SBR]Seed Receiving/"+ {view.params.AI} + "/Gross Unit")

You don't need to add the .value part.

Soham, a tip: Wiki - how to post code on this forum.

This will work, but note that for performance you should really use two custom properties with indirect tag bindings, and do the sum in a single expression referencing those two custom properties. The tag() function can't be optimized the same way indirect tag bindings can, so it's a performance pitfall.

4 Likes

Fixed that for you.

Really, if you are using the tag() expression function in a User Interface binding, you are screwing up. Full stop.

The only appropriate place to use the tag() expression function is to perform indirection within an expression tag. Nowhere else.

Phil, you can suggest this be included in the manual. Drop them a line: docs@inductiveautomation.com!

It worked. Thanks alot

Read

and

You start using that in multiple places you will eventually have to pay the piper.

can you explain it? I didn't get you

The Tag() expression function i've used can't be optimized as well as an indirect tag binding.
Given that, the best way to achieve this will be to instead of using two Tag() functions, we'll create two custom properties on your component, let's call them tagValue and tagUnit and each of them will have an indirect binding and they'll look something like this:


Then on your props.text property instead of the expression with two Tag() functions, you'll just add the two properties together like this:

{this.custom.tagValue} + {this.custom.tagUnit}
4 Likes

okay great explanation. Thankyou so much @leonardo.godoi