cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

listing Things of a Template while omitting some Things

leisel
1-Visitor

listing Things of a Template while omitting some Things

I have 4 Things representing different sensors that share the same Template. I want a User to be able to select different 'Scenes' which are just different groupings of these sensors (1&2&3 or 1&3&4 etc.).

The problem is, I don't know how to represent this or if there even would be a good way to do so. I was assuming I would use Lists to show the different Scenes (not to select anything, just to see the groupings). I know how to fill a list with Things based on a Template that they share, but can't find or think of a way to show the Things of a Template while omitting one or two.

Is something like this possible? Is there a way to do this with/without the Template?

ACCEPTED SOLUTION

Accepted Solutions
adrianpet
12-Amethyst
(To:leisel)

Hi,

   You have the option to filter. In your case, you must select the QueryImplementingthingsWithData service from your Thing Template. From the bottom right area select query(edit query) and create a Query. You will select "Add Filter" and from the listed properties just select "name", next select one of the listed properties(Starts with, Contains, Ends With or Is Exactly) and fill in the field and click the green box to add it and press ok. If you have a thingtemplate with 4 things(for example Thing1, Thing2, Thing3, Thing4)  that are using that template and you want to just list Thing2 and Thing4 in your list widget, just add filter for Contains with value Thing2 and another filter with Contains with Thing4.

Thank you,

Adrian

View solution in original post

5 REPLIES 5
vmihai
12-Amethyst
(To:leisel)

Hi Levi,

You could omit some things that implement the same Template by creating your own version of the getImplementingThingWithData service of that template. You create your own custom service and you use if  blocks to filter out the Things you don't want to be returned by the method. The result of the service will be an infotable with the same datashape as the one used by the initial getImplementingThingsWithData service. You can then use this service to populate the list in your Mashup.

I hope this helps,

Veronica

leisel
1-Visitor
(To:vmihai)

unfortunately I'm not very experienced in writing scripts involving thingworx data. I know it'd be an easy fix to write some IF statements, but what i'm currently working on never made it necessary to understand the syntax of the javascript combined with our thingworx type of things.

A few tutorials I've watched let me do some things involving our own written scripts, but understanding them never stuck with me. Is there any tutorial/webpage that can explain the simple things that should be known before writing scripts? There's a lot I don't know but a solid starting point could clear everything up.

Like if I could actually see the code of a service like "getImplementingThingsWithData" I could then understand how to do it myself. Unless I've somehow missed it, I haven't figured out a way to see the inner workings of our thingworx functions/services.

vmihai
12-Amethyst
(To:leisel)

Hi Levi,

You can find more about ThingWorx Services in the Help Center and also on the plms training

Digital Media Publisher

I am not aware if there is a way to see the code for the getImplementingThingWithData service of a Template..., but you can use the snippets sections when building a script. This will help you get started with the specific syntax used by ThingWorx Entities.

Veronica

adrianpet
12-Amethyst
(To:leisel)

Hi,

   You have the option to filter. In your case, you must select the QueryImplementingthingsWithData service from your Thing Template. From the bottom right area select query(edit query) and create a Query. You will select "Add Filter" and from the listed properties just select "name", next select one of the listed properties(Starts with, Contains, Ends With or Is Exactly) and fill in the field and click the green box to add it and press ok. If you have a thingtemplate with 4 things(for example Thing1, Thing2, Thing3, Thing4)  that are using that template and you want to just list Thing2 and Thing4 in your list widget, just add filter for Contains with value Thing2 and another filter with Contains with Thing4.

Thank you,

Adrian

Thank you. I didn't know this existed.

It's kinda weird how we are filtering what's allowed in, rather than filtering to keep something out, but this solves my problem.

Announcements
Top Tags