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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Standalone service

byutz
12-Amethyst

Standalone service

So I have ran into a few cases where I need a service to do something, but I dont exactly have a specific thing it should be attached too.  For example, I want to display a table of all equipment.  I have 3 types of equipment, all with different thing templates because they are drastically different. Which one gets the service?  Or should I create an arbitrary service thing and just call it to my mashup?  I just want to do the best practice, not something that just works

ACCEPTED SOLUTION

Accepted Solutions

Hi Brian,

I didn't saw any best practices for this yet on ThingWorx, but I what I usually do it's to create a helper thing for this cases called:

"WhateverMatter"Helper

And add any services for "WhateverMatter" on this Thing.

This is usually what you would do in other programing languages as Static functions, but as ThingWorx doesn't have Static services, you have to rely on Things with services, no ThingTemplates has this services are not Template of any child class.

View solution in original post

4 REPLIES 4
Aanjan
12-Amethyst
(To:byutz)

Brian, you would have to write your own service for this. For example, if you have bunch of Things based on one Template, you can use GetImplementingThingsWithData to retrieve all Things based on that Template. But in your case, since they are different, you would have to treat them as separate/ individual Things.

If you go to Resources-> EntityServices from the Composer, there is a service called GetEntityList. That would give you a list of all Entities based on what you give as input (Thing, ThingTemplate, DataShape etc). You would then have to sift through that table to get your required list.

Hi Brian,

I didn't saw any best practices for this yet on ThingWorx, but I what I usually do it's to create a helper thing for this cases called:

"WhateverMatter"Helper

And add any services for "WhateverMatter" on this Thing.

This is usually what you would do in other programing languages as Static functions, but as ThingWorx doesn't have Static services, you have to rely on Things with services, no ThingTemplates has this services are not Template of any child class.

byutz
12-Amethyst
(To:CarlesColl)

Thanks Carles.  Thats exactly what I did.  I cant think of any better way to do it, and it worked great.

This is how I normally approach it also.  I have a "GenericServiceThing" or something similar when a service is not for a specific Template

Announcements


Top Tags