Skip to main content
1-Visitor
June 12, 2019
Solved

Referencing Widgets in Services

Hi all,

 

I've been developing in Thingworx for a while now and I was wondering if it was possible to reference a Widget Property in a service, something like:

if (condition) {

     [WidgetProperty] = [Something];

} else {

     [WidgetProperty] = [SomethingElse];

}

 

I know that Widgets have pre-defined services and inputs/outputs but my question is: Could I write a code that defines the input of the property based on a condition? If possible, how do I reference this property in the service?

 

Thank you.

mnarangAnswer
5-Regular Member
June 13, 2019

You can not access widget reference in Thingworx JS service .This is doable in Studio (which is another AR product ) using angular snippet . But as per Thingworx it is not feasible .But you can use expression/Validator widget to evaluate a JS expression(condition) and use the output to bind to widget services .

 

Thanks ,

Mukul Narang 

5 replies

mnarang5-Regular MemberAnswer
5-Regular Member
June 13, 2019

You can not access widget reference in Thingworx JS service .This is doable in Studio (which is another AR product ) using angular snippet . But as per Thingworx it is not feasible .But you can use expression/Validator widget to evaluate a JS expression(condition) and use the output to bind to widget services .

 

Thanks ,

Mukul Narang 

Translate
tscur1-VisitorAuthor
1-Visitor
June 13, 2019

Thank you for your answer @mnarang !

 

I've never used the Expression/Validador Widget, could you help me understand how it works?

 

Regards,

Taciano

Translate
5-Regular Member
June 13, 2019

For expression widget - https://support.ptc.com/cs/help/thingworx_hc/thingworx_7.0_hc/index.jspx?id=ExpressionWidget&action=show

 

There is also a video link for how to use expression widget in above link .

 

For Validator widget - https://support.ptc.com/cs/help/thingworx_hc/thingworx_7.0_hc/index.jspx?id=ValidatorWidget&action=show

One more: - https://www.ptc.com/en/support/article/CS250781

 

Let me know if you face any problem after seeing these links .

 

Thanks ,

Mukul Narang 

Translate