# String to Expression

**URL:** <https://forum.inductiveautomation.com/t/string-to-expression/115356>\
**Category:** Module Development\
**Tags:** vision\
**Created:** [May 1, 2026, 9:35pm UTC](https://forum.inductiveautomation.com/t/string-to-expression/115356 "2026-05-01T21:35:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![channing](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/channing/32/85151_2.png) [@channing](https://forum.inductiveautomation.com/u/channing)\
**Post date:** [May 1, 2026, 9:35pm UTC](https://forum.inductiveautomation.com/t/string-to-expression/115356/1 "2026-05-01T21:35:04Z")

</div>

To add an ExpressionPropertyAdapter adapter to my vision window's FPMIWindow.InteractionController I need to run setExpression() on the adapter.

Is there a quick way to parse my expression string to the object structure expected by ExpressionPropertyAdapter.setExpression?

```java
private void bindExpression(InteractionController ic, JComponent target, String propName, String expression, Class<?> valueClass) {
        // EXAMPLE
        // String expression = "getBit({Root Container.test_template_3.tag2},10) &&\ngetBit({Root Container.test_template_3.tag3},10)"

        ExpressionPropertyAdapter a = new ExpressionPropertyAdapter();

        // build expression
        com.inductiveautomation.ignition.common.expressions.Expression e = null; // <--- How to initialize this from String expression ?

        a.setExpression(e);
        a.setExpressionSource(expression);
        a.setTarget(target);
        a.setTargetPropertyDynamic(true);
        a.setTargetPropertyName(propName);
        a.setValueClass(valueClass);

        ic.setPropertyAdapter(target, propName, a);
    }

```

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [May 1, 2026, 10:01pm UTC](https://forum.inductiveautomation.com/t/string-to-expression/115356/2 "2026-05-01T22:01:15Z")

</div>

Check this out:

> **[ELParserHarness](https://sdk.inductiveautomation.com/javadoc/ignition81/8.1.33/com/inductiveautomation/ignition/common/expressions/parsing/ELParserHarness.html)**
>
> declaration: package: com.inductiveautomation.ignition.common.expressions.parsing, class: ELParserHarness

---

<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:** [May 1, 2026, 10:08pm UTC](https://forum.inductiveautomation.com/t/string-to-expression/115356/3 "2026-05-01T22:08:53Z")

</div>

Note that the work is in preparing an ExpressionParseContext for your target component's environment.

---

<div class="post-metadata">

**Author:** ![channing](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/channing/32/85151_2.png) [@channing](https://forum.inductiveautomation.com/u/channing)\
**Post date:** [May 1, 2026, 10:10pm UTC](https://forum.inductiveautomation.com/t/string-to-expression/115356/4 "2026-05-01T22:10:50Z")

</div>

Thanks,

ELParserHarness requires an ExpressionParseContext, which is where I get stuck.

Trying to figure out how to use ExpressionParseContext right now. Tips?

EDIT: @pturmel yessir. Wondering if there's a builtin ExpressionParseContext?

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [May 1, 2026, 10:13pm UTC](https://forum.inductiveautomation.com/t/string-to-expression/115356/5 "2026-05-01T22:13:17Z")

</div>

I know of this one by @paul-griffith :

> <https://github.com/paul-griffith/ignition-extensions/blob/5aba12e3f5b891a4feca3fb311aa5840f40d76b9/common/src/main/java/org/imdc/extensions/common/UtilitiesExtensions.java#L103-L132>

---

<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:** [May 1, 2026, 10:19pm UTC](https://forum.inductiveautomation.com/t/string-to-expression/115356/6 "2026-05-01T22:19:32Z")

</div>

Pretty sure you need [this one](https://sdk.inductiveautomation.com/javadoc/ignition81/8.1.47/com/inductiveautomation/ignition/gateway/expressions/PropertyBasedExpressionParseContext.html), but I'm not sure how to set it up properly.

🤷‍♂️

I suspect some of the key bits you need for Vision aren't in the javadocs.

---

<div class="post-metadata">

**Author:** ![channing](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/channing/32/85151_2.png) [@channing](https://forum.inductiveautomation.com/u/channing)\
**Post date:** [May 1, 2026, 10:20pm UTC](https://forum.inductiveautomation.com/t/string-to-expression/115356/7 "2026-05-01T22:20:48Z")

</div>

I found that one too! 🙂

Looks promising. Trying to get intellj to resolve the classpath right now...

Edit: Not sure if it's available at the designer scope. classpath goes [...]igntion.gateway.[...]

---

<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:** [May 1, 2026, 10:27pm UTC](https://forum.inductiveautomation.com/t/string-to-expression/115356/8 "2026-05-01T22:27:27Z")

</div>

```java
    ELParserHarness parser = new ELParserHarness();
    FunctionFactory functionFactory = new ComponentFunctionFactory(context);
    ExpressionParseContext binder =
        BindUtilities.newBinder(window, context.getTagManager(), null, functionFactory);

```

EDIT: Though I'll mention, it looks like potential problems abound:

```python
    ExpressionPropertyAdapter newAdapter = new ExpressionPropertyAdapter();

    // Go through the expression tree and connect all of the BoundVariableExpressions
    try {
      BindUtilities.connectBindings(window, context.getTagManager(), expr, newAdapter, newAdapter);
    } catch (RuntimeException e) {
      if (e.getMessage().isEmpty()) {
        ErrorUtil.showError("Unknown error occurred during bound variable connection.", e);
      } else {
        ErrorUtil.showError(e.getMessage(), e);
      }
      return false;
    }

    Component component = context.getComponent();

    context.getController().removePropertyAdapter(component, propName);
    newAdapter.setExpression(expr);
    newAdapter.setExpressionSource(binding.expression);
    newAdapter.setOverlayOptOut(binding.overlayOptOut);

```

---

<div class="post-metadata">

**Author:** ![channing](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/channing/32/85151_2.png) [@channing](https://forum.inductiveautomation.com/u/channing)\
**Post date:** [May 1, 2026, 10:50pm UTC](https://forum.inductiveautomation.com/t/string-to-expression/115356/9 "2026-05-01T22:50:02Z")

</div>

_ **Winner, winner, chicken dinner!** _  
Massive, unbelievable dubs today, guys. Thank you so much for your help @bmusson @pturmel @paul-griffith !

```java
private void bindExpression(BindingRoot win, JComponent target, String propName, String expression, Class<?> valueClass) {
        // EXAMPLE
        // String expression = "getBit({Root Container.test_template_3.tag2},10) &&\ngetBit({Root Container.test_template_3.tag3},10)"

        ExpressionPropertyAdapter a = new ExpressionPropertyAdapter();

        // build expression
        ELParserHarness p = new ELParserHarness();
        FunctionFactory ff = context.getExpressionFunctionFactory();
        ExpressionParseContext ctx = BindUtilities.newBinder(win, context.getTagManager(), null, ff);
        Expression e = null;
        try {
            e = p.parse(expression, ctx);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }

        // Go through the expression tree and connect the BoundVariableExpressions
        try {
            BindUtilities.connectBindings(win, context.getTagManager(), e, a, a);
        } catch (RuntimeException ex) {
            if (ex.getMessage().isEmpty()) {
                ErrorUtil.showError("Unknown error occurred during bound variable connection.", ex);
            } else {
                ErrorUtil.showError(ex.getMessage(), ex);
            }
        }

        a.setExpression(e);
        a.setExpressionSource(expression);
        a.setTarget(target);
        a.setTargetPropertyDynamic(true);
        a.setTargetPropertyName(propName);
        a.setValueClass(valueClass);

        win.getInteractionController().setPropertyAdapter(target, propName, a);
    }

```
