Expression binding, dynamic path to a property?

Hi,

In Perspective, is there a way in an Expression binding to have a dynamic path to a property of a component on the view ?
Here's the structure that I have:
image
I want to apply a style to the numeric field "limit" depending on the value of the numeric field "entry". Here's my code for now:

if({this.props.value} != None && {../Conductivity_entry.props.value} != None && {this.props.value} < {../Conductivity_entry.props.value}, "LimitsControl/LimitResponsible", "LimitsControl/NormalLimit")

What I want is to replace "{../Conductivity_entry.props.value}" by a dynamic path with the name of the container. I tried something like "{../}+{parent.meta.name}+{_entry.props.value}" but it's not working, and I don't find a solution.
Is that possible ?
Thanks

Have you tried property() ?

https://docs.inductiveautomation.com/display/DOC81/property

5 Likes

In case you ever need to do something in a script, this topic covers that,

Thanks that should work, but I'm not able to write the right path, I tried
property("../" + {parent.meta.name} + "_entry.props.value") and some other things but it doesn't work, can you give me a clue ?

Well I tried to add a script below the Expression binding, I was able to make it work but the problem that I had is for the update. The style was updated when I refreshed the page, and I want the style to be updated when I change the values.

Not really following, if you change the style, then the style should update. Try changing the style in the designer to see it working, just type it in for now.

You'll need to show more of your work to really know what's going on.

Sure, I tried this:

Basically I want to change the style of a field depending of the values of this field and another field. When I tried with this script it worked, but the style was updated only when I refreshed my page, while I want the script to be updated when I enter a wrong value

Hover over the expression error and it will show you details on the error. From your screenshot, there is something wrong with the expression.

Yeah it's "normal" because the value of this field is dynamic, it depends of the page I open so the expression can't find a value in the designer, but it's actually working. The problem is for the update, the style change when I refresh the page

By the way I had something similar in the past, I had an expression following by a script like this and I had the same problem, the changes that the script was supposed to apply were applied when I updated the page

The transform will only execute when the expression value changes, so keep that in mind.

1 Like

Oh okay that makes sense! I understand now, thanks for that

I guess I will try to solve my initial problem with just an expression, but can you help me for a last thing ?
I'm not able to write properly the path of the property I want in the property() function.
This is the initial path : {../Conductivity_entry.props.value}
This is the path for the value of another field that is in the same container of the field I'm writing the expression. "Conductivity" is the name of the container so I'd like to make this path dynamic
I tried something like : property("../" + {parent.meta.name} + "_entry.props.value")
but it's not working, what am I doing wrong ?

Maybe this example will help, paste JSON (right click on a view).

Change propIndirect and you will see propPath change to the value in the label, assuming it's a valid path.

{
  "custom": {
    "propIndirect": "Label_0",
    "propPath": "Label 2"
  },
  "params": {},
  "propConfig": {
    "custom.propIndirect": {
      "persistent": true
    },
    "custom.propPath": {
      "binding": {
        "config": {
          "expression": "property(\"/root/\" + {view.custom.propIndirect} + \".props.text\")"
        },
        "type": "expr"
      },
      "persistent": true
    }
  },
  "props": {},
  "root": {
    "children": [
      {
        "meta": {
          "name": "Label"
        },
        "position": {
          "height": 32,
          "width": 279,
          "x": 82,
          "y": 105
        },
        "props": {
          "text": "Label 1"
        },
        "type": "ia.display.label"
      },
      {
        "meta": {
          "name": "Label_0"
        },
        "position": {
          "height": 32,
          "width": 279,
          "x": 82,
          "y": 167
        },
        "props": {
          "text": "Label 2"
        },
        "type": "ia.display.label"
      }
    ],
    "meta": {
      "name": "root"
    },
    "type": "ia.container.coord"
  }
}

Okay I think I got it, but I have this now:

image

I have Ignition 8 so I should have the property function

If you enter the function properly the text should be blue. Maybe start smaller, create some custom props and get the property() working first. IMO that is cleaner anyways. Then use the custom props in your expressions.

Edit, I don't know when the function was released, the 8.1 docs don't state. The 8.0 docs do.

According to this:

https://docs.inductiveautomation.com/display/DOC80/property

It was introduced in v8.0.4. Are you still on v8.0?

Well I know that I'm using Ignition v8 but I can't find the complete description of the version so I don't know what version of the v8 I have, where can I find it ?
I checked the gateway and the "about Ignition designer"

It's in both those places...

Yes but

image

You might be running a nightly pre-release version of 8.0.4.

You really need to upgrade.

1 Like

Oh okay, I'll look into it, thanks