Skip to main content
1-Visitor
December 3, 2020
Solved

Error on create Thing

  • December 3, 2020
  • 1 reply
  • 2647 views

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?

 

Best answer by mgoel

@mmancin 

 

Check this if it works or not.

 

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

 

Regards,

Mohit

1 reply

5-Regular Member
December 3, 2020

@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

mmancin1-VisitorAuthor
1-Visitor
December 3, 2020

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

mgoel5-Regular MemberAnswer
5-Regular Member
December 3, 2020

@mmancin 

 

Check this if it works or not.

 

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

 

Regards,

Mohit