4 Replies Latest reply on Oct 14, 2015 9:46 AM by mikew RSS
    byutz Apprentice

    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

      • Re: Standalone service
        aanjan Heavyweight Champ

        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.

        • Re: Standalone service
          carlesc Ninja

          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.