# Indirect Tagging in Expression

**URL:** <https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting\
**Created:** [March 4, 2024, 4:04pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771 "2024-03-04T16:04:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soham\_Ambekar](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Soham\_Ambekar](https://forum.inductiveautomation.com/u/Soham_Ambekar)\
**Post date:** [March 4, 2024, 4:04pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/1 "2024-03-04T16:04:30Z")

</div>

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?

 ![1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e68173545af92320551473e3b5bd7837da2580d2.png)

---

<div class="post-metadata">

**Author:** ![leonardo.godoi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/leonardo.godoi/32/27178_2.png) [@leonardo.godoi](https://forum.inductiveautomation.com/u/leonardo.godoi)\
**Post date:** [March 4, 2024, 4:09pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/2 "2024-03-04T16:09:17Z")

</div>

Try:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 4, 2024, 4:20pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/3 "2024-03-04T16:20:57Z")

</div>

Soham, a tip: [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 4, 2024, 4:38pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/4 "2024-03-04T16:38:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 4, 2024, 4:54pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/5 "2024-03-04T16:54:01Z")

</div>

> [@paul-griffith](#):
>
> performance ~~pitfall~~ _ **disaster** _.

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.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 4, 2024, 4:57pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/6 "2024-03-04T16:57:40Z")

</div>

> [@pturmel](#):
>
> Really, if you are using the `tag()` expression function in a User Interface binding, you are screwing up.

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

---

<div class="post-metadata">

**Author:** ![Soham\_Ambekar](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Soham\_Ambekar](https://forum.inductiveautomation.com/u/Soham_Ambekar)\
**Post date:** [March 4, 2024, 5:37pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/7 "2024-03-04T17:37:23Z")

</div>

> [@leonardo.godoi](#):
>
> ```auto
> tag("[SBR]Seed Receiving/"+ {view.params.AI} + "/Gross Value") +
> tag("[SBR]Seed Receiving/"+ {view.params.AI} + "/Gross Unit")
> 
> ```

It worked. Thanks alot

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 4, 2024, 5:45pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/8 "2024-03-04T17:45:26Z")

</div>

> [@Soham\_Ambekar](#):
>
> It worked. Thanks alot

Read

> [@paul-griffith](#):
>
> 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

and

> [@pturmel](#):
>
> The **only** appropriate place to use the `tag()` expression function is to perform indirection within an **expression tag**. Nowhere else.

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

---

<div class="post-metadata">

**Author:** ![Soham\_Ambekar](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Soham\_Ambekar](https://forum.inductiveautomation.com/u/Soham_Ambekar)\
**Post date:** [March 4, 2024, 6:11pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/9 "2024-03-04T18:11:20Z")

</div>

can you explain it? I didn't get you

---

<div class="post-metadata">

**Author:** ![leonardo.godoi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/leonardo.godoi/32/27178_2.png) [@leonardo.godoi](https://forum.inductiveautomation.com/u/leonardo.godoi)\
**Post date:** [March 4, 2024, 7:16pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/10 "2024-03-04T19:16:57Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/6/a60cc6c73de3c48a92d31bd7f826356c0bf80f11.png)  
Then on your props.text property instead of the expression with two Tag() functions, you'll just add the two properties together like this:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/b/ab9bcc9d37a845076771e4a41ab4c3c9de0252c2.png)

```auto
{this.custom.tagValue} + {this.custom.tagUnit}

```

---

<div class="post-metadata">

**Author:** ![Soham\_Ambekar](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Soham\_Ambekar](https://forum.inductiveautomation.com/u/Soham_Ambekar)\
**Post date:** [March 4, 2024, 7:31pm UTC](https://forum.inductiveautomation.com/t/indirect-tagging-in-expression/86771/11 "2024-03-04T19:31:59Z")

</div>

okay great explanation. Thankyou so much @leonardo.godoi
