cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ravipuri
Level: Powered On

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
ravipuri
Level: Powered On

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
JayadeepT
Level: Powered On

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
TopShelf-MSFT
Level 10

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

Hi @ravipuri 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 

ravipuri
Level: Powered On

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
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,135)