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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Error on create Thing

mmancin
10-Marble

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?

 

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
10-Marble
(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
10-Marble
(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

Announcements


Top Tags