cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Anonymous
Not applicable

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
Anonymous
Not applicable

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,

 

@Anonymous 

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

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