Skip to main content
May 21, 2019 2:21 PM UTC
Solved

Updating Property Attributes Programmatically

Is there any possible way to update a Thing's Property attributes (Read Only, Persistent, Base Type, Category, etc) via script?  I found the service 'SetPropertyLogging' for turning on/off data logging, but I can't find any similar service to take care of the other attributes.  

I want to be able to use a Service to update these aspects for many already-existing properties at once.

posipovaAnswer
May 24, 2019 5:14 PM UTC

Currently not part of ThingWorx functionality https://www.ptc.com/en/support/article?n=CS281204

I'd try to work with REST calls. In your browser, open dev tools (f12 in chrome). When you update your property attributes manually, note the requests showing up in the Network tab. It should show the request and headers.

4 replies

May 21, 2019 2:53 PM UTC

Try "AddPropertyDefinition".

 

me.AddPropertyDefinition({
defaultValue: undefined /* STRING */,
remoteBindingAspects: undefined /* JSON */,
description: undefined /* STRING */,
readOnly: undefined /* BOOLEAN */,
remote: undefined /* BOOLEAN */,
type: undefined /* BASETYPENAME */,
remotePropertyName: undefined /* STRING */,
timeout: undefined /* INTEGER */,
pushType: undefined /* STRING */,
dataChangeThreshold: undefined /* NUMBER */,
logged: undefined /* BOOLEAN */,
name: undefined /* STRING */,
pushThreshold: undefined /* NUMBER */,
dataChangeType: undefined /* STRING */,
category: undefined /* STRING */,
persistent: undefined /* BOOLEAN */,
dataShape: undefined /* DATASHAPENAME */
});

May 21, 2019 2:58 PM UTC

I did try this.  This service will throw an error because it's trying to create a property with a name that already exists.  I could delete my properties and recreate, but I'd like to avoid that scenario.

posipovaAnswer
May 24, 2019 5:14 PM UTC

Currently not part of ThingWorx functionality https://www.ptc.com/en/support/article?n=CS281204

I'd try to work with REST calls. In your browser, open dev tools (f12 in chrome). When you update your property attributes manually, note the requests showing up in the Network tab. It should show the request and headers.

Nov 8, 2019 9:57 PM UTC

Hi @Ascherer17.

 

If the response provided by Constantine answered your question, please mark it as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon