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

 

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

Administrator
Administrator

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})})

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 62 members 3,937 guests
Please welcome our newest community members: