cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rolivier
Helper I
Helper I

Patch or Update?

I have been spending hours trying to figure something out and can't.   Seems like it should be easy, but I'm struggling!

 

I have 2 tables.  "DailyPaperwork" and "HazardAssessment".   Both have been created using an offline collection and then the data will be sent to SQL Server.   While offline, the tables are connected by a "FieldKey".   

I send the "DailyPaperwork" table to SQL and get a UniqueID from the server.   Now I need to Update?/Patch? that unique ID from the DailyPaperwork table over to all the other tables (all currently linked with a "FieldKey"). 

 

I have tried about 1000 versions of "ForAll(...Update()).  ForAll(...Patch()).  UpdateIf...  Patch..."  I just can't get anything to work.   Any help would be appreciated.  Thanks in advance.  

DailyPaperwork:
ID: 123 (obtained from server)
FieldKey: 789789789

HazardAssessment
ForignID: (Null)
FieldKey: 789789789

I want to Patch/Update the ID from DailyPaperwork into the ForignID field in HazardAssessment (using the FieldKey as a common reference).  


Note:   There may be many records so I need a “bulk” method.  Also, not all of the foreign keys will be null.  So the logic I envision is. 

ForAll(Hazardassessment, Forignid = blank(),

Update(...)

);

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @rolivier ,

You can use either 

ForAll(
   DailyPaperwork As aData,
   Patch(
      HazardAssessment,
      {FieldKey:aData.FieldKey},
      {ForeignID:aData.ForeignID}
    )
)

or

ForAll(
   DailyPaperwork As aData,
   UpdateIf(
      HazardAssessment,
      FieldKey=aData.FieldKey,
      {ForeignID:aData.ForeignID}
    )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @rolivier ,

You can use either 

ForAll(
   DailyPaperwork As aData,
   Patch(
      HazardAssessment,
      {FieldKey:aData.FieldKey},
      {ForeignID:aData.ForeignID}
    )
)

or

ForAll(
   DailyPaperwork As aData,
   UpdateIf(
      HazardAssessment,
      FieldKey=aData.FieldKey,
      {ForeignID:aData.ForeignID}
    )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

You have no idea how helpful this was!!!!  I had the logic all correct, but I think it was the identical field names that were causing me problems.   I didn't realize you could "AS" your way out of it!   

I was struggling with ambiguous field names in another situation and ended up with an ugly workaround.  This is so clean.   

 

THANK YOU!!!!

 

Happy to help @rolivier ,

As is a handy tool for disambuiguation.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,636)