Skip to main content
1-Visitor
February 17, 2017
Solved

While creating a thingtemplate,how to compare thingtemplate's properties name against existing thingtemplate

While creating a thingtemplate,and want compare thingtemplate's properties names against existing  thingtemplate properities name, I want to validate that we reuse thingtemplate and do not create if there is one that have the necessary properties

posipovaAnswer
20-Turquoise
February 20, 2017

It's not available on the template level, but you may try to use GetInstancePropertyDefinitions with the infotable returned. Please keep in mind you cannot "test" a service on the template level, you would have to create a new service in a thing and access the template services through it.

8 replies

20-Turquoise
February 17, 2017

Could you please clarify - you are creating a thingtemplate and comparing the property names against a different thingtemplate? Or adding new properties to the newly created thingtemplate and comparing them to the existing ones in the same template?

You may use try/catch and run a service on the property, if it doesn't exist and you get an error, then proceed to creating one.

Translate
aluna1-VisitorAuthor
1-Visitor
February 17, 2017

What I am trying to do is while creating a new thingtemplate, compare the properties names again existing thingtemplates

Translate
20-Turquoise
February 17, 2017

Such a service is not available out of the box. What I see as a workaround/potential solution, is to keep all existing properties in some datatable, then checking for a matching entry before creating a new property. Or running the GetProperties service that returns an infotable and comparing the row value.

Translate
5-Regular Member
February 20, 2017

Hi armando luna​, If this Issue is resolved; could you please mark correct answer to let other members know that this Thread has a solution.

Translate
aluna1-VisitorAuthor
1-Visitor
February 20, 2017

just one thing, I do not find the GetProperties service

Translate
posipova20-TurquoiseAnswer
20-Turquoise
February 20, 2017

It's not available on the template level, but you may try to use GetInstancePropertyDefinitions with the infotable returned. Please keep in mind you cannot "test" a service on the template level, you would have to create a new service in a thing and access the template services through it.

Translate