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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

create a thing dynamically using a service and then configure it to the created project

shussain1
7-Bedrock

create a thing dynamically using a service and then configure it to the created project

I have created a project(Project A) , Template and a thing. Now i need to create 10 things dynamically using a service and then each service has to be configure a project (Project A). I am able to create a thing using a service CreateThings but while using this service it doesn''t provide the param named as project so that i can provide the name of the project  that i want it to be binded.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Slangley,

 

Adding the answer for the above ques:

 

Step1: Need to create a thing and enable it. use the below service for the same:

var params = {
name: 'Thingabc'/* STRING */,
description: undefined /* STRING */,
thingTemplateName: 'ProjectTemplate' /* THINGTEMPLATENAME */,
tags: undefined /* TAGS */
};

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

Things["vc"].EnableThing();
Things["vc"].RestartThing();

 

Step2: Then use a service to bind this thing to a project as shown below:

 

var params = {
searchExpression: 'Thingabc' /* STRING */,
types: 'Thing' /* JSON */,
tags: undefined /* TAGS */
};

// no return
Projects["ProjectName"].AddEntities(params);

 

Regards,

Saddam

View solution in original post

4 REPLIES 4

got the answer.

slangley
23-Emerald II
(To:shussain1)

Hi @shussain1.

 

Glad you found the solution you needed.  Would you mind sharing the details of that solution and then marking your response as the Accepted Solution?  That will help others who may have similar questions.

 

Regards.

 

--Sharon

Hi Slangley,

 

Adding the answer for the above ques:

 

Step1: Need to create a thing and enable it. use the below service for the same:

var params = {
name: 'Thingabc'/* STRING */,
description: undefined /* STRING */,
thingTemplateName: 'ProjectTemplate' /* THINGTEMPLATENAME */,
tags: undefined /* TAGS */
};

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

Things["vc"].EnableThing();
Things["vc"].RestartThing();

 

Step2: Then use a service to bind this thing to a project as shown below:

 

var params = {
searchExpression: 'Thingabc' /* STRING */,
types: 'Thing' /* JSON */,
tags: undefined /* TAGS */
};

// no return
Projects["ProjectName"].AddEntities(params);

 

Regards,

Saddam

slangley
23-Emerald II
(To:shussain1)

Hi @shussain1.

 

Thank you so much for sharing your solution and marking it as the Accepted Solution!  You involvement in the community is greatly appreciated.

 

Regards.

 

--Sharon

 

 

Top Tags