cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to add item to collection which is a property of a parent collection?

I am trying to add more items to Location property but unable to via Patch or Collect

ClearCollect(
    incomingPeople,
    {
        Id: 10,
        Locations: [{Geography: "UK"}]
    }
);

Clear(selectedPeople);

ForAll(
    incomingPeople,
    Collect(
        selectedPeople,
        {
            Id: Id,
            Locations: ForAll(
                Locations,
                {Geography: Value.Geography}
            )
        }
    )
)

Attempt 1 - fail

Collect(LookUp(selectedPeople,Id=10).Locations, {Geography: "France"})

Attempt 2 - fail

Patch(LookUp(selectedPeople,Id=10).Locations, 
// not sure what to put as 2nd param,
{Geography: "France"})

Another attempt - fail

 

Patch(selectedPeople
, LookUp(selectedPeople,Id=10),
{Locations2:ForAll([{Geography:"France"}], {Geography:Value.Geography})})
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Anonymous
Not applicable

Re: How to add item to collection which is a property of a parent collection?

Got it to work 

 

Patch(items, LookUp(items, Id=ThisItem.Id), {Locations:ForAll(currentLocations, {Geography:Geography, Division : Division, Country:Country, City:City, ProvinceState : ProvinceState})})

 

View solution in original post

3 REPLIES 3
Highlighted
Frequent Visitor

Re: How to add item to collection which is a property of a parent collection?

ClearCollect(
incomingPeople,
{
Id: 10,
Locations: [{Geography: "UK"}]
}
);

Clear(selectedPeople);

ForAll(
incomingPeople,
Collect(
selectedPeople,
{
Id: Id,
Locations: Locations
}
)
);

 

 

Patch(selectedPeople,LookUp(selectedPeople,Id=10),{Locations:Collect(LookUp(selectedPeople,Id=10).Locations,[{Geography:"France"}])})

Highlighted
Community Champion
Community Champion

Re: How to add item to collection which is a property of a parent collection?

Hi @Anonymous thanks for posting in the PowerApps community. Are you still having trouble with adding an item and can you review the above reply and advise if it was helpful? 

 

Thank you,

 

@TopShelf-MSFT 

Highlighted
Anonymous
Not applicable

Re: How to add item to collection which is a property of a parent collection?

Got it to work 

 

Patch(items, LookUp(items, Id=ThisItem.Id), {Locations:ForAll(currentLocations, {Geography:Geography, Division : Division, Country:Country, City:City, ProvinceState : ProvinceState})})

 

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,532)