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

Re: Using 2 CDS entities as data sources on one form?

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

View solution in original post

2 REPLIES 2
Highlighted
Anonymous
Not applicable

Re: Using 2 CDS entities as data sources on one form?

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.

 

 

 

 

Highlighted
Anonymous
Not applicable

Re: Using 2 CDS entities as data sources on one form?

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

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,650)