Skip to main content
4-Participant
Jan 31, 2024 9:18 AM UTC
Solved

use of GetServiceDefinitions for uncategorized services

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.

Rocko
RockoAnswer
19-Tanzanite
Feb 1, 2024 1:33 PM UTC

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.

14 replies

16-Pearl
Jan 31, 2024 12:38 PM UTC

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.

Translate
4-Participant
Jan 31, 2024 2:08 PM UTC

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

 

 

Translate
12-Amethyst
Feb 1, 2024 7:34 AM UTC

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?

Translate
Rocko
19-Tanzanite
Apr 30, 2024 9:44 AM UTC

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);
Translate
4-Participant
Apr 30, 2024 11:18 AM UTC

Thank you, thats the very good solution.

Translate