Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Hi,
According to the posts below :
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
Solved! Go to Solution.
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
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
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