cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Using 2 CDS entities as data sources on one form?

Hi, Wondering anyone has experience saving data to 2 CDS data sources on one form. I am designing a PowerApp for Dynamics 365 Talent and the requirement is to save a new record on a form to 2 existing CDS entities. Let's call 'Worker Bank Account' entity the main driving entity. It has a one-to-many relationship to 'Bank Account Disbursement' via the field 'Bank Account'. The requirement is to put fields from both entities on one form so user can enter new bank account details. When the save button is clicked, a new record is created in both entities (linked by 'Bank Account'). Is this doable? I searched and so far what I found is a YouTube video showing how to save to the driving data source using some fields from another data source (and it only reads from it not writing any new data back) and another one showing how to write to 2 SharePoint lists with a one-to-many relationship by manually generating the linkage field. Thanks in advance.
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

I ended up using Flow to do 2 inserts one after another.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

After quite of bit of searching I found the Patch or Collect may the way to meet this requirement.

 

However, 'Bank Account Disbursement' has 3 required fields, 2 of them are lookup fields to other entities. 

 

Found it hard to referennce the fields correctly. Tried the code like below and PowerApps keeps saying field name is invalid:

 

SubmitForm(Form1);Patch('Bank Account Disbursements',Defaults('Bank Account Disbursements'), {cdm_bankaccountdisbursementnumber:"XXXXXXX",cdm_workerbankaccountnumber:AccountNumberValue.Text,cdm_companycode:LookUp(Companies,cdm_companycode="MA")});ResetForm(Form1)

 

There is a blog here talking about using Patch to create records: https://sachinbansal.blog/2018/06/04/common-data-service-for-apps-canvas-app-update-patch-lookup-val..., I followed the exact method and it didn't work.

 

 

 

 

Anonymous
Not applicable

I ended up using Flow to do 2 inserts one after another.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,048)