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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to Enable a Thing in the code

pshashipreetham
17-Peridot

How to Enable a Thing in the code

Hi,

 

I am trying to create a Thing and assigning a value to the Properties that are inherited from the Thing Template, below is the code.

 

Resources["EntityServices"].CreateThing({
	name: "testfty" /* STRING */,
        thingTemplateName: "testfty.TT.testfty" /* THINGTEMPLATENAME */,
	projectName: "comP" /* PROJECTNAME */,
});

Things["testfty"].Enable();
Things["testfty"].Restart();

Things["testfty"].Property1= 32;
Things["testfty"].Property2= 56;

 

But I am getting the following error:

 

Error executing service addSensor. Message :: TypeError: Cannot find function Enable in object com.thingworx.things.ConfiguredThing@a3e81bb. - See Script Error Log for more details.

 

 


Thanks,

 

 

Shashi Preetham
1 ACCEPTED SOLUTION

Accepted Solutions

 

Please use EnableThing/RestartThing
Things["testfty"].Enable(); --> Things["testfty"].EnableThing();
Things["testfty"].Restart(); --> Things["testfty"].RestartThing();

 

View solution in original post

2 REPLIES 2

 

Please use EnableThing/RestartThing
Things["testfty"].Enable(); --> Things["testfty"].EnableThing();
Things["testfty"].Restart(); --> Things["testfty"].RestartThing();

 

And, as a reminder for others in case of similar situations, all the Services available for a Thing are available in the Services section, so you can verify it a service with that name exists there, OR in the service editor you can select as a reference another entity, and at this point you will also see all its services.

VladimirRosu_0-1686209683248.png

 

Top Tags