Skip to main content
Ascherer17
16-Pearl
May 21, 2019
Solved

Updating Property Attributes Programmatically

  • May 21, 2019
  • 2 replies
  • 3102 views

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.

Best answer by posipova

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.

2 replies

20-Turquoise
May 21, 2019

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

Ascherer17
16-Pearl
May 21, 2019

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.

posipova20-TurquoiseAnswer
20-Turquoise
May 24, 2019

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.

Support
November 8, 2019

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