Skip to main content
5-Regular Member
December 9, 2020
Question

How to check for invalid characters in property name

  • December 9, 2020
  • 1 reply
  • 1344 views

Hi,

 

I'm looking for a way to validate a property name before it gets created. Basically, the name of the property is chosen at Runtime by a user, so I'll need to double-check if the Name entered for the property is valid.

 

Is there a service I can use to verify a specified Name for service AddPropertyDefinition?

 

Thanks!

1 reply

5-Regular Member
December 9, 2020

Hello @a_labrecque ,

 

Regarding a a way to validate a property name before it gets created there is a similar community post which might help you

 

https://community.ptc.com/t5/ThingWorx-Developers/Code-Snippet-to-check-if-any-property-already-exist-in-thing/m-p/664093#M44880

 

 

Hope it helps,

5-Regular Member
December 9, 2020

Hi @Ciprian-Traian,

 

Thanks for the response. However, the post you linked me too doesn't contain what I'm looking for.

 

I'll probably have to create a service to replicate how Thingworx validates if a property name is valid by looking if the string starts with a letter and if it contains invalid character (such as whitespace). I'm a bit reluctant to do so, since I may overlook some cases, and if the Thingworx validation ever gets updated, my service won't be in sync.