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 III
Super User III

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 III
Super User III

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (83,741)