How to Enable a Thing in the code
Jun 07, 2023
10:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jun 07, 2023
10:22 AM
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,
Email: psp316r@outlook.com,
Mobile: +91 8099838001.
Email: psp316r@outlook.com,
Mobile: +91 8099838001.
Solved! Go to Solution.
Labels:
- Labels:
-
Best Practices
-
Examples
ACCEPTED SOLUTION
Accepted Solutions
Jun 07, 2023
10:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jun 07, 2023
10:40 AM
Please use EnableThing/RestartThing
Things["testfty"].Enable(); --> Things["testfty"].EnableThing();
Things["testfty"].Restart(); --> Things["testfty"].RestartThing();
2 REPLIES 2
Jun 07, 2023
10:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jun 07, 2023
10:40 AM
Please use EnableThing/RestartThing
Things["testfty"].Enable(); --> Things["testfty"].EnableThing();
Things["testfty"].Restart(); --> Things["testfty"].RestartThing();
Jun 08, 2023
03:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jun 08, 2023
03:34 AM
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.
