cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper III
Helper III

Using forall to collect the data

Hi All,

 

 I have a collectionA which is having Name and ID columns. I'm populating a combobox with Names by using(collectionA)  and it was enabled for selecting multiple items.

 

Here i have to collect the data forall the Names with corresponding ID.

 

ClearCollect(MyCalendarNames,combobox.SelectedItems.DisplayName);

ForAll(collectionA.Name,

ClearCollect(collectionX ,Filter(Office365Outlook.GetEventsCalendarViewV2(
LookUp(collectionY,DisplayName in MyCalendarNames.Name).ID,
Text(DateAdd(dpkFrom.SelectedDate,-1,Hours),UTC),
Text(DateAdd(dpkTo.SelectedDate,1,Days),UTC)).value));

 

Can someone help me on this.

 

4 REPLIES 4
Dual Super User
Dual Super User

@BKGOUD 

 

I did a POC on your requirement.

 

On App start, I created a collection as below:

ClearCollect(colIDNames,Table({ID:1,DisplayName:"A"},{ID:2,DisplayName:"B"},{ID:3,DisplayName:"C"},{ID:4,DisplayName:"D"},{ID:5,DisplayName:"E"}))

 

Placed a combo box on the screen and its Items property set to colIDNames.DisplayName.

 

On change property of the combo box, I placed following formula to get all the names and IDs:

ClearCollect(colNames, Filter(colIDNames,DisplayName in cbNames.SelectedItems))

 

With above formula, you will get only the selected items.

 

Please check and let me know if you can use it to resolve your issue.

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

Hi @rsaikrishna ,

Thanks for helping me.

The solution which you have shared works fine. I need help  on the below code.

 

ForAll(collectionA.Name,

ClearCollect(collectionX ,Filter(Office365Outlook.GetEventsCalendarViewV2(
LookUp(collectionY,DisplayName in MyCalendarNames.Name).ID,
Text(DateAdd(dpkFrom.SelectedDate,-1,Hours),UTC),
Text(DateAdd(dpkTo.SelectedDate,1,Days),UTC)).value));

 

which was returning single record eventhough if we morethan 1 Name in collectionA.Name.

@BKGOUD 

 

In your ForAll, you are using ClearCollect which is clearing the collection for every item in collectionA.Name loop.

 

You may need to use Collect in the place of ClearCollect.

 

Give a try and let me know if this helps.

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

Hi @rsaikrishna ,

 

I have tried by removing Clear but no luck.

We have multiple names with corresponding ID.

collectionA: 

NameID
ABC001
XYZ002

 

collectionB: 

NameID
ABC001
XYZ002

 

ForAll(collectionA.Name,

Collect(collectionX ,Filter(Office365Outlook.GetEventsCalendarViewV2(
LookUp(collectionY,Name in collectionB.Name).ID// Here im using LookUp and returns same ID eachtime. 
Text(DateAdd(dpkFrom.SelectedDate,-1,Hours),UTC),
Text(DateAdd(dpkTo.SelectedDate,1,Days),UTC)).value));

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Solution Authors
Top Kudoed Authors
Users online (31,930)