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
JayadeepT
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"}])})

TopShelf-MSFT 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
secondImage

Community User Group Member Badges

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

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (6,974)