I have the results of a query ran multiple times to store the results into a single variable. I have tried Obj1.concat(Obj2) and Obj1.push(Obj2) but I get this error consistently unable to add entry to final list - TypeError: Cannot find function concat in object DynamicWrapper (Instance) : [vCACCAFEPageOdataRequest]-[class com.vmware.vcac.platform.rest.client.query.PageOdataRequest] -- VALUE : com.vmware.vcac.platform.rest.client.query.PageOdataRequest@743cf0d.
Has anyone come across a different way to do this?
Here is how you can return combined result from users on the pageData and pageData2:
var result = [];
var users = authenticationGroupService.getUsersInGroup(tenant, adGroup, null, pageData);
result = result.concat(users);
var users = authenticationGroupService.getUsersInGroup(tenant, adGroup, null, pageData2);
result = result.concat(users2);
return result; // array with combined items from pageData and pageData2
So the idea is to start from an empty array, then fetch the items for a given page, and concatenate them with the list of items processed so far.
Of course, the above assumes you have exactly two pages with items. In production code, you may not know the exact number of items, so you should use a loop to iterate over page 1, 2, ... etc. until you cannot fetch more items.
Could you provide the code showing what exactly you are trying to achieve?
Looking at vRO API Explorer, indeed the type vCACCAFEPageOdataRequest has no methods concat() or push().
function getUsersInGroup(tenant, adGroup, authenticationGroupService){
var pageNum = 1;
var query = new vCACCAFEOdataQuery();
var pageData = new vCACCAFEPageOdataRequest(pageNum,100,query);
if(pageData.next()){
pageNum++;
var pageData2 = new vCACCAFEPageOdataRequest(pageNum,100,query);
// add pageData2 to pageData
}
return authenticationGroupService.getUsersInGroup(tenant, adGroup, null, pageData);
Its pretty simple. I am trying to get the results of both pageData and pageData2 into the same object so I can return the results.
I think you'll need to loop through the contents of each page and stuff that into an array or put each page into an array. You could also make your page size larger so just one page is created.
Here is how you can return combined result from users on the pageData and pageData2:
var result = [];
var users = authenticationGroupService.getUsersInGroup(tenant, adGroup, null, pageData);
result = result.concat(users);
var users = authenticationGroupService.getUsersInGroup(tenant, adGroup, null, pageData2);
result = result.concat(users2);
return result; // array with combined items from pageData and pageData2
So the idea is to start from an empty array, then fetch the items for a given page, and concatenate them with the list of items processed so far.
Of course, the above assumes you have exactly two pages with items. In production code, you may not know the exact number of items, so you should use a loop to iterate over page 1, 2, ... etc. until you cannot fetch more items.
That is exactly how it ended up.