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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Adding multiple 'category' to properties, services and events

amittal-3
13-Aquamarine

Adding multiple 'category' to properties, services and events

Hello,

Is it possible to add/set multiple category to same property or service? When we define a property in a Thing, there is a provision also to add a Category (which is helpful in organising and searching), so I would like to know if I can put a property/service in multiple category? If yes, then how?

To better understand what I mean please refer the attached screen shot. So in the screen shot I have 2 properties, property t1 has (better to say, I tried to put) category as POLLED, PLOTTABLE while t2 has category as POLLED. What I would want is when I call the service (generic service) 'GetPropertyDefinitions' with category parameter as POLLED, I should get both t1 and t2 (right now I am only getting t2) and when I call the same service with category parameter as PLOTTABLE, I should get only t1 (right now I am getting nothing).

Please suggest if that's possible.

Thanks in advance

Regards

Aditya Mittal

1 ACCEPTED SOLUTION

Accepted Solutions
amittal-3
13-Aquamarine
(To:mneumann)

Hello @mneumann,

I got what I was looking for. I should say it was very nearby, but I couldn't just see it :-)

The way to get/read the category of a property is:

me.GetNamedProperties({propertyNames:{"items":["myProp1"]}}).dataShape.fields["myProp1"].category;

Thanks for your support.

Regards

Aditya

View solution in original post

7 REPLIES 7

Hi,

the Category seems to be based on a STRING variable.

http://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/#page/ThingWorx%2FHelp%2FComposer%2FThings%2FThingProperties%2FProgrammaticallyAddingPropertiestoThings.html

 

I don't think that it will split it into arrays - but it will just consider it as a whole.

It might be an option to write a custom service, which is based on the GetPropertyDefinitons (get back all of them) and then split the Category and filter for the split values.

 

Cheers,

Michael

amittal-3
13-Aquamarine
(To:mneumann)

Hi Michael,

Thanks for your reply. Continuing on your suggestion do you know how can I read the category of a Property? I mean when I checked, I think I found that 'category' field does not belong to aspects. For your reference I am attaching the Property definition from XML, and there since I didn't find category as aspects.category unlike other fields such as 'aspect.isLogged' or 'aspect.isPersistent' so I am thinking that maybe I cannot read category using aspects. I am not sure if my assumption is correct or not.

 

<PropertyDefinition aspect.cacheTime="0.0" aspect.dataChangeType="VALUE" aspect.isLogged="false" aspect.isPersistent="false" aspect.isReadOnly="false" baseType="STRING" category="POLLED PLOTTABLE" description="" isLocalOnly="false" name="t1" ordinal="1"/>

Thanks

Aditya

Hi @amittal-3

you would need this service output and pass it to another service which is then using the

https://www.w3schools.com/jsref/jsref_split.asp split() Method on the category.

With this result you can operate on the category array - e.g. to check or return individual categories.

 

The output of the new custom service can then be used instead of the original GetPropertyDefinitons.

 

Cheers,

Michael

amittal-3
13-Aquamarine
(To:mneumann)

Hello @mneumann,

Thanks for your reply. When you said - 


you would need this service output


what do you mean by "this"? Were you trying to point to some service by which I can get the category of the propert(y/ies)? Because what you said about using the 'split' method, will be helpful once I am able to read the category aspect of the property.

In my previous post what I meant to ask was how can I read/get the category of any property, using some service. To be more specific to get the 'units' aspect of a property I can get it as - 

me.GetNamedProperties({propertyNames:{"items": "myProp1"}}).dataShape.fields[selectedParam].aspects.units

so in similar way how can I read/get 'Category' aspect?

Thanks in advance for bearing with me!!

Regards

Aditya

Sorry @amittal-3

thanks for explaining it again - I think I misunderstood something in the beginning.

I'll try to see what can be done here and come back to you.

amittal-3
13-Aquamarine
(To:mneumann)

Hello @mneumann,

I got what I was looking for. I should say it was very nearby, but I couldn't just see it :-)

The way to get/read the category of a property is:

me.GetNamedProperties({propertyNames:{"items":["myProp1"]}}).dataShape.fields["myProp1"].category;

Thanks for your support.

Regards

Aditya

Hi @amittal-3

That's quite clever. Nice to see it's working for you.

As there isn't really a intuitive default service to retrieve the Category, I've also opened an internal enhancement request with Product Management / R&D to assess if such a service could be implemented in any of the future releases.

 

Cheers,

Michael

Top Tags