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

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

Error on create Thing

mmancin
9-Granite

Error on create Thing

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
mgoel
17-Peridot
(To:mmancin)

@mmancin 

 

Check this if it works or not.

 

Things['abc'].EnableThing();
Things['abc'].RestartThing();

 

Regards,

Mohit

View solution in original post

5 REPLIES 5
mgoel
17-Peridot
(To:mmancin)

@mmancin 

 

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

mmancin
9-Granite
(To:mgoel)

@mgoel 

 

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.

mgoel
17-Peridot
(To:mmancin)

@mmancin 

 

Check this if it works or not.

 

Things['abc'].EnableThing();
Things['abc'].RestartThing();

 

Regards,

Mohit

mmancin
9-Granite
(To:mgoel)

@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)

mgoel
17-Peridot
(To:mmancin)

@mmancin 

 

Welcome, Could you please mark my answer accept as solution for the benefit of other community users. It will be helpful.

 

Regards,

Mohit

Top Tags