Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hi all, I've installed TW9.1.0 and I try to create new thing into service with this script:
var params = {
name: "NewThingName",
thingTemplateName: "GenericThing"
};
Resources["EntityServices"].CreateThing(params);
Things["NewThingName"].Enable();
Things["NewThingName"].Restart();
But always give this error:
Error executing service AA. Message :: TypeError: Cannot find function Enable in object com.thingworx.things.ConfiguredThing@20a84ab1. - See Script Error Log for more details.
what am I doing wrong?
Solved! Go to Solution.
Check this if it works or not.
Things['abc'].EnableThing();
Things['abc'].RestartThing();
Regards,
Mohit
Thanks for opening this post on community. I tried with below code and its working.
let params = {
name: 'abc' /* STRING */,
description: 'xyz' /* STRING */,
thingTemplateName: 'GenericThing' /* THINGTEMPLATENAME */,
projectName:'PTCDefaultProject' /* PROJECTNAME */,
//tags: undefined /* TAGS */
};
// no return
Resources["EntityServices"].CreateThing(params);
Regards,
Mohit
Have you try to Enable and Restart Thing?
Things["abc"].Enable();
Things["abc"].Restart();
I received always the same message
Error executing service aa. Message :: TypeError: Cannot find function Enable in object com.thingworx.things.ConfiguredThing@96aeb2a. - See Script Error Log for more details.
Check this if it works or not.
Things['abc'].EnableThing();
Things['abc'].RestartThing();
Regards,
Mohit
@mgoel now it works! Thanks.
I follow this guide
https://community.ptc.com/t5/IoT-Tech-Tips/Creating-a-Thing-in-Service-Script/td-p/533427
but I see it's wrong (or maybe it's just to update)
Welcome, Could you please mark my answer accept as solution for the benefit of other community users. It will be helpful.
Regards,
Mohit