cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BKGOUD
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
rsaikrishna
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
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

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

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (29,312)