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

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

SOLVED
Level 7

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

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

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

4 REPLIES 4

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

got the answer.

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

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

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

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

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

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