# Using a Multi State Indicator value to reference a SQLtag

**URL:** <https://forum.inductiveautomation.com/t/using-a-multi-state-indicator-value-to-reference-a-sqltag/7951>\
**Category:** Ignition\
**Created:** [February 4, 2014, 4:40pm UTC](https://forum.inductiveautomation.com/t/using-a-multi-state-indicator-value-to-reference-a-sqltag/7951 "2014-02-04T16:40:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![njsd](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@njsd](https://forum.inductiveautomation.com/u/njsd)\
**Post date:** [February 4, 2014, 4:40pm UTC](https://forum.inductiveautomation.com/t/using-a-multi-state-indicator-value-to-reference-a-sqltag/7951/1 "2014-02-04T16:40:00Z")

</div>

Hello,

I would like to use the state of a multistate indicator to reference a sqltag. For example:

When the state is:  
21   
the indicator text value is the same as the current value of the tag:  
 “S90/HMI/Torque Value”

I don’t want to set up an expression based on the state because I have something like 45 values, and I want other people to be able to diagnose this code later.

Anyways to do this intuitively?

Thank you

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 4, 2014, 5:00pm UTC](https://forum.inductiveautomation.com/t/using-a-multi-state-indicator-value-to-reference-a-sqltag/7951/2 "2014-02-04T17:00:38Z")

</div>

Can you give me a few examples of states? Hard to formulate a plan based on one example… 😃

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [February 4, 2014, 8:44pm UTC](https://forum.inductiveautomation.com/t/using-a-multi-state-indicator-value-to-reference-a-sqltag/7951/3 "2014-02-04T20:44:40Z")

</div>

If you store the ID and Descriptions in a database, then you could get the value from the database in a custom property with this expression binding:

CustomProp:

```auto
runScript("system.db.runScalarQuery('SELECT StateTag FROM States WHERE StateID = 21')")
```

then you would use indirect binding in the Text Field:

Indirect Tag Path: {1}

References:  
Ref # 1 -\> Property Path: Root Container.Text Field.CustomProp

---

<div class="post-metadata">

**Author:** ![njsd](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@njsd](https://forum.inductiveautomation.com/u/njsd)\
**Post date:** [February 5, 2014, 2:59pm UTC](https://forum.inductiveautomation.com/t/using-a-multi-state-indicator-value-to-reference-a-sqltag/7951/4 "2014-02-05T14:59:03Z")

</div>

Thanks for the quick replies.

What I was hoping for was a way inside the Designer GUI to reference the value of a string SQLtag as the text for a state. I know that this can be accomplished both with scripting and with sql calls, but this project is going to be maintained by people who are not as Ignition affluent. I would like a more intuitive way for them to be able to accomplish this task.

Example of the goal of this task:

Some way to syntactically reference in the text column of this dataset viewer a SQLtag.   
i.e. When the state of the above component is 19 instead of saying “SMART FRAME PICK ACTIVE” it would say [S90\Station\_20\HMI\Pick String] Where the tag at that location held a string value of a pick string.

Other HMI creation programs have a way to embed a tag value into the text of a given state of a multistate indicator. (e.g. Factory Talk ViewStudio). Maybe this post should be a future state request for Ignition as a platform.

Thank you

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 5, 2014, 7:48pm UTC](https://forum.inductiveautomation.com/t/using-a-multi-state-indicator-value-to-reference-a-sqltag/7951/5 "2014-02-05T19:48:14Z")

</div>

Ok, makes sense now.

Actually, I’d given up using multistate indicators a while ago for similar reasons. I ended up rolling my own, since we don’t use animation here.

I make mine using a standard label with a dataset attached to store process steps, Descriptions, and background color

For this one, I added a column that stores a tag path.

Finish up with some lookup functions bound to different properties, and concatenate the text together.

Here’s a sample.  
[attachment=0]IndirectTest.vwin[/attachment]  
EDIT: Just had a DOH! moment… actually, you could add similar properties to a multistate and do the same lookups. You can then concatenate the results and bind it to the text property. That would give the animation options back.  
[attachment=3]2014-02-05\_14-14-53.png[/attachment][attachment=2]2014-02-05\_14-29-47.png[/attachment][attachment=1]2014-02-05\_14-33-30.png[/attachment]

---

<div class="post-metadata">

**Author:** ![njsd](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@njsd](https://forum.inductiveautomation.com/u/njsd)\
**Post date:** [February 10, 2014, 4:40pm UTC](https://forum.inductiveautomation.com/t/using-a-multi-state-indicator-value-to-reference-a-sqltag/7951/6 "2014-02-10T16:40:02Z")

</div>

That’s a great solution, Jordan.

Thanks for the help! ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")
