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

Bulk update of Entity field that using lookup Field

Hi Everyone,

I have question that I have not seen a post for. I have a project that the requirements need a new field added to the entity that was using a lookup to another entity

 

Entity:

Entity Name: Inventory Item

Entity Field: Inventory Group (Field I want to do bulk update on)>>> This field has lookup defined to 'Inventory Groups' (Entity) with a field called 'Inventory Group' with ten values … we will call one of the values "New Company"

 

Lookup:

Entity Name: Inventory Groups

Entity Field: Inventory Group (Key Field and used as lookup field)

 

I was thinking of just creating a button to fill in the blanks of all the new values in the dataset. I know power BI might be easier, but now just curious to find the error in my logic. I was looking at using a ForAll function, but definitely have something wrong with formatting.

My first thought was this:

 

 

ForAll('Inventory Items',{'Inventory Group':First(Filter('Inventory Groups','Inventory Group'="New Company"))})

 

 

This does not cause any errors but does not update anything on the table.

 

Then I was thinking I need to use a Patch function inside the ForAll statement, but this just creates errors that "you cannot use Patch on the same dataset" of the Forall Function.

 

Does anyone have an idea of how I would change all values of the field 'Inventory Group'  to say a text value "New Company". For simplicity we will just say we want to change all record of the entity 'Inventory Item' (I can work out the filters later).

 

Thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Bulk update of Entity field that using lookup Field

Hi @JasonF ,

Do you want to update a lookup field of Inventory Item(all the record)?

Could you tell me the Key Field of Inventory Item entity?

I assume it as key field name, please replace with the real field name.

If so, please try this:

1)create a collection with the data of Inventory Item:

ClearCollect(a,Inventory Item)

 2)update:

ForAll(a,Patch(Inventory Item,LookUp(Inventory Item,key field name=a[@key field name]),{Inventory Group:LookUp(Inventory Groups,'Inventory Group'="New Company")}))

 //if you want to update all the records/multiple records, you need to firstly create a collection with the data of the records that you want to update.

 

Here's a doc about how to bulk update records for your reference:

https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Bulk update of Entity field that using lookup Field

Hi @JasonF ,

Do you want to update a lookup field of Inventory Item(all the record)?

Could you tell me the Key Field of Inventory Item entity?

I assume it as key field name, please replace with the real field name.

If so, please try this:

1)create a collection with the data of Inventory Item:

ClearCollect(a,Inventory Item)

 2)update:

ForAll(a,Patch(Inventory Item,LookUp(Inventory Item,key field name=a[@key field name]),{Inventory Group:LookUp(Inventory Groups,'Inventory Group'="New Company")}))

 //if you want to update all the records/multiple records, you need to firstly create a collection with the data of the records that you want to update.

 

Here's a doc about how to bulk update records for your reference:

https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

JasonF
Level: Powered On

Re: Bulk update of Entity field that using lookup Field

Thanks ,

That worked. A little slow, but it worked. 

Here is the final equation:

 

ClearCollect(a,'Inventory Items');ForAll(a,Patch('Inventory Items',LookUp('Inventory Items','Item No'=a[@'Item No']),{'Inventory Group':LookUp('Inventory Groups','Inventory Group'="New Company")}))

 

Thanks Again,

Jason

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

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 Solution Authors
Top Kudoed Authors
Users online (5,122)