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

is RestartThing necessary when creating thing from script service ?

SOLVED
seanccc
Peridot

is RestartThing necessary when creating thing from script service ?

Hi, 

According to the posts below : 

https://community.ptc.com/t5/ThingWorx-Developers/Dynamically-create-enable-and-restart-Things-in-a-...

https://community.ptc.com/t5/IoT-Tech-Tips/Creating-a-Thing-in-Service-Script/td-p/533427

 

    var params = {

        name: "NewThingName",

        thingTemplateName: "GenericThing"

    };

    Resources["EntityServices"].CreateThing(params);

    Things["NewThingName"].EnableThing();

    Things["NewThingName"].RestartThing();

 

 

The step is CreateThing->EnableThing->RestartThing ,  but in my test , I found thing works well even if I don't call the service RestartThing.   is this step still necessary in ThingWorx 9.1.0  ?    

 

Regards,

Sean

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: is RestartThing necessary when creating thing from script service ?

@seanccc 

 

Thanks for reaching out to us. I just test the below code in 9.1 version.


let params = {
name: 'MG2' /* STRING */,
description: undefined /* STRING */,
thingTemplateName: 'GenericThing' /* THINGTEMPLATENAME */,
projectName: 'PTCDefaultProject' /* PROJECTNAME */,
tags: undefined /* TAGS */
};

// no return
Resources["EntityServices"].CreateThing(params);
Things["MG2"].EnableThing();

 

Thing is enabled after running this, no need to restart. By default project is Mandatory in Thingworx 9.1 version. Hope this is your answer.

 

Regards,

Mohit

View solution in original post

2 REPLIES 2

Re: is RestartThing necessary when creating thing from script service ?

@seanccc 

 

Thanks for reaching out to us. I just test the below code in 9.1 version.


let params = {
name: 'MG2' /* STRING */,
description: undefined /* STRING */,
thingTemplateName: 'GenericThing' /* THINGTEMPLATENAME */,
projectName: 'PTCDefaultProject' /* PROJECTNAME */,
tags: undefined /* TAGS */
};

// no return
Resources["EntityServices"].CreateThing(params);
Things["MG2"].EnableThing();

 

Thing is enabled after running this, no need to restart. By default project is Mandatory in Thingworx 9.1 version. Hope this is your answer.

 

Regards,

Mohit

View solution in original post

Re: is RestartThing necessary when creating thing from script service ?

Hi @seanccc 

 

If you feel above response is the resolution of your query, could you please mark it as accept solution for the benefit of other community members.

 

Regards,

Mohit

Announcements

Check out the upcoming Expert Session: Understanding ThingWorx Navigate Licensing in Community "Customer Events" section.