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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

is RestartThing necessary when creating thing from script service ?

seanccc
17-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-webservice/td-p/576907

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

 

ACCEPTED SOLUTION

Accepted Solutions
mgoel
17-Peridot
(To:seanccc)

@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
mgoel
17-Peridot
(To:seanccc)

@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

mgoel
17-Peridot
(To:mgoel)

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


Top Tags