Skip to main content
1-Visitor
January 18, 2017
Question

Changing image on condition in mashup

  • January 18, 2017
  • 5 replies
  • 5020 views

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.

5 replies

5-Regular Member
January 18, 2017

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

1-Visitor
January 19, 2017

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.

1-Visitor
June 1, 2018

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. 

1-Visitor
June 1, 2018

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

20-Turquoise
January 19, 2017

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

5-Regular Member
June 4, 2018

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.

1-Visitor
November 19, 2018

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.