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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Combine contents of from templates

Tomellache2B
14-Alexandrite

Combine contents of from templates

Hello.

 

I would like to combine 3 the contents (Things) from three different thing template and output these things onto a list. I have tried multiple ways still I get errors.

Please can you give me suggestions.

 

Regards.

 

1 ACCEPTED SOLUTION

Accepted Solutions
abjain
13-Aquamarine
(To:Tomellache2B)

@Tomellache2B : Created a sample service. Please check below. 

 

// result: INFOTABLE dataShape: "RootEntityList"
let thinglist = ThingTemplates["testTT"].GetImplementingThings(); //Get all things associated with testTT thing template
var thingName;
var params = {

infoTableName: "MyInfoTable",

dataShapeName: "nameds"

};

var MyInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params); // Creating an empty infotable from 'nameds' data shape which has a 'name' field with 'String' as base type 

 

for each (var row in thinglist.rows) {

// Now each row is already assigned to the row variable in the loop

thingName= row.name;
MyInfoTable.AddRow({name: thingName}); // adding name of things in the rows of infotable

}
me.info1=MyInfoTable; //Here on the last row I am storing the thing names in  an infotable property 

View solution in original post

4 REPLIES 4
abjain
13-Aquamarine
(To:Tomellache2B)

@Tomellache2B Can you please provide more details? What exactly you are combining in Things and where? Whats the error are you getting?

Tomellache2B
14-Alexandrite
(To:abjain)

Hello @abjain

 

I have three thing templates. Each template contains things.

I want to output a list that has the names of the things found inside of each template.

The aim is to have 3 different infotables each containing names of things from the three different templates. Then have one combined infotable to store all the thing names from each infotable.

 

Each one of these infotables make use of the same Datashape.

 

What I have currently:

1. Created empty 3 infotables (each template can store the names of its things inside an infotable )

2. I used the getImplentingThings service to output the names of things (the output type is infotable)

3. I need to find a way to populate the empty infotables with the names of things

4. I will need a combined infotable that will aggregate the 3 infotables.

 

I am stuck on completing step 3.

Any suggestions?

abjain
13-Aquamarine
(To:Tomellache2B)

@Tomellache2B : Created a sample service. Please check below. 

 

// result: INFOTABLE dataShape: "RootEntityList"
let thinglist = ThingTemplates["testTT"].GetImplementingThings(); //Get all things associated with testTT thing template
var thingName;
var params = {

infoTableName: "MyInfoTable",

dataShapeName: "nameds"

};

var MyInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params); // Creating an empty infotable from 'nameds' data shape which has a 'name' field with 'String' as base type 

 

for each (var row in thinglist.rows) {

// Now each row is already assigned to the row variable in the loop

thingName= row.name;
MyInfoTable.AddRow({name: thingName}); // adding name of things in the rows of infotable

}
me.info1=MyInfoTable; //Here on the last row I am storing the thing names in  an infotable property 

Tomellache2B
14-Alexandrite
(To:abjain)

This gives the desired output, additionally I made a nested for loop that will iterate through the different templates and output the thing names from each template.

 

Many thanks.

Top Tags