Skip to main content
1-Visitor
October 8, 2019
Question

Multiple selection list call a single service that gets data for each of the selected Things

  • October 8, 2019
  • 1 reply
  • 2307 views

We don’t know how to develop the following in a mashup. We have a multiple choice drop down list with different items that represent a Thing on the platform and we’ll like to call a single service that gets iteratively all the data for each of the selected items to represent them on a time series chart widget. 

Currently, we’ve developed one service for each of the selected items and we call them one by one, but we understand this is not the way to do it. We’ve developed 4 different services and this way we can visualize data for a maximum of 4 different Things selected on the list, but we have 70 different item to select for.

Thanks in advance,

1 reply

18-Opal
October 8, 2019

Hello,

 

The service that provides the content for your list, it has "Selected rows". What you need to do is bind this "Selected rows" to some input parameter of type INFOTABLE of the service which processes selected data. This way, if the user selects several items in the list, this INFOTABLE will contain only those items, and you'll be able to process them in the second service.

 

/ Constantine

AinhoaH1-VisitorAuthor
1-Visitor
October 8, 2019

Thanks for the quick reply. 

 

We already have those "selected rows" as input parameter of our service, but we want to iterate through them and call a service that gets the data for each of them to visualize all of the results in the same time series chart.

Each of the selected item from the list is a Thing and it has to be a datasource and in the time series chart we only display one property of the Thing.

 

Thank you, 

 

18-Opal
October 8, 2019

Hello,

 

I would suggest you to iterate through those selected rows inside that service and aggregate results, something like that:

 

var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
 infoTableName : "InfoTable",
 dataShapeName : "MyDataShape"					// TODO: Use correct data shape name
});

for (var i = 0; i < selected.rows.length; ++i) {	// TODO: "selected" is the input parameter
 var row = selected.rows[i];
 var r = me.ProcessRow({ row: row });			// TODO: Use correct service name
	result = Resources["InfoTableFunctions"].Union({ 
 t1: result, 
 t2: r 
 });
}

 

/ Constantine