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

Updating Property Attributes Programmatically

Highlighted
Amethyst

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.

3 REPLIES 3

Re: Updating Property Attributes Programmatically

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 */
});

Re: Updating Property Attributes Programmatically

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.

Re: Updating Property Attributes Programmatically

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.