Skip to main content
1-Visitor
Jan 18, 2017 8:17 AM UTC
Question

Changing image on condition in mashup

Hello,

I would like to do a red/green light alert based on a boolean condition in my mashup.

How can I do that? Do I need to make a service?

I would like it to be responsive as well.

If you have any clues, thanks for helping me out.

10 replies

5-Regular Member
Jan 18, 2017 8:23 PM UTC

I think you could do this using the Expression widget or the Validator widget ​. Hope this helps!

Translate
1-Visitor
Jan 19, 2017 9:36 PM UTC

Hello,

As Tori mentioned, you can use expression, connected with e.g. image. Within the expression's widget configuration panel you can add a property of the necessary type. Then, based on this property change / value, you can add an expression. The expression could have a different output, it can also be e.g. a string - name of media entity to be shown as an image (red/ green "light" image).

In case of any additional questions, don't hesitate to ask.

Regards,

J.

Translate
1-Visitor
Jun 1, 2018 10:09 AM UTC

HI J,

 

Was wondering if you could help me out. newbie to Mashups. Can't get this to work. I can get to as far as having a input to the expression and an output value. Can't figure out how you configure the output to select an image based on it's value and how to change it on the Mashup. Any help would be greatly appreciate. 

Translate
1-Visitor
Jun 1, 2018 3:36 PM UTC

Got it working with the Validator that the image is visible/invisible. Can't determine how to choose a different image. Any ideas?

Translate
20-Turquoise
Jan 19, 2017 10:59 PM UTC

Here is some more information on the Expression widget (requires support login): https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS233996&lang=en_US

and the Validator widget https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS250781&lang=en_US

Translate
5-Regular Member
Jun 4, 2018 2:19 AM UTC

I'll vote for @CarlesColl 's solution in using the value display widget in showing different images, since that's what I usually do as well.

 

But in your condition, since you only need a Red/Green Light in Boolean status, you can have a more direct way to do this.

 

1. Look for a default widget called Shape (and it's responsive)

2. Put it in your mashup, and choose a ShapeType you need 

3. Bind your Boolean data to the widget

3. Add a State Formatting for it, For true, give it a Green style, for False, give it a Red style.

Translate
1-Visitor
Nov 19, 2018 2:12 PM UTC

What I did was put my image on a panel and then another image that I wanted it to change to if my property changed to a specific value.

  • I then made sure that the "Visible" setting was checked for the default image. I put the image that I wanted it to change to over my default image and then made the "Visible" setting to unchecked. 
  • Next I inserted a validator widget. Mouse over the widget to select the configure widget option from the drop down.
  • Add parameter = property_name. base type = number (in my case). 
  • Then I dragged the output option over to my image that needs to be visible when property_name = 1 (in my case). and then chose the visible option for the binding.
  • I dragged my "property_name" value from my GetImplementingThingsWithData to my validator widget and selected "property_name"
  • I then went back to the validator widget and set the settings to AutoEvaluate checked and output checked.
  • I then added this expression to the expression field : 
if(property_name==1){Visible="true"} else{Visible="false"}

And it worked.

Translate