Skip to main content
4-Participant
January 31, 2024
Solved

use of GetServiceDefinitions for uncategorized services

  • January 31, 2024
  • 2 replies
  • 3277 views

Hello,

with the service:

 

result = Things[thingName].GetServiceDefinitions({

    category: category /* STRING */, ,

    type: undefined /* BASETYPENAME */, ,

    dataShape: undefined /* DATASHAPENAME */

});

 

i can get all servicedefinitons of services of a special category.
But which Sting do I need to use if i want to get all uncategoriezed services?

I've tried *Uncategoriezed*", "'Uncategoriezed*", "**Uncategoriezed**", " ", "", "uncategoriezed", "*uncategoriezed*", "**uncategoriezed**", nothing.

All of them are wrong.

Does anyone have any idea what the right string is?

 

We use thingworx 9.1.8 and 9.3.7.

Best answer by Rocko

Assuming you know all the existing categories, here's what you can do: Query all services and subtract all the services returned by querying for all the categories. What's left over are the services without category. Not super-efficient, but it could work - under the assumption.

2 replies

16-Pearl
January 31, 2024

Hi @DJ_9605282 

 

Try to use this: 

let result = Things['Thing'].GetServiceDefinitions({
category: undefined /* STRING */,
type: undefined /* BASETYPENAME */,
dataShape: undefined /* DATASHAPENAME */

});

where category is undefined, you should get all services that do not have a category. 

Regards.

4-Participant
January 31, 2024

Thanks for your reply,
Unfortunately, I tried this and as a result I get all the services, with or without a category.

 

 

12-Amethyst
February 1, 2024

What if you keep call like this, but then sort result by category == null / undefined? Maybe this is not direct method, but hope it will work?

Rocko
19-Tanzanite
April 30, 2024

Here's a slightly more elegant solution giving you an array of uncategorized services defined on the current thing:

 

let entityDef = Resources["EntityServices"].ReadEntityDefinitionAsJSON({name:"YourThingName", type:"Things"});
let sDefs=entityDef.effectiveShape.serviceDefinitions;
let services=Object.keys(sDefs).filter(s=> !sDefs[s].category && !sDefs[s].sourceName);
4-Participant
April 30, 2024

Thank you, thats the very good solution.