1

Need to insert a new record in parent entity with lookup fields. After the insert use the value of one column of the new record to insert the child entity which uses the column as a lookup field as well.

I am designing a PowerApps Canvas Form to insert data into 2 related CDS entities. I got confirmation from a PowerApps guru that I can use 2 Patch() functions to perform the inserts - first insert a record in the parent entity 'Worker Bank Accounts', then use the same 'Bank Account Number' to insert a new record into the 'Bank Account Disbursements' entity.

The issue I am having is with referencing the 'look up' fields in my code. It seems like because the way CDS is designed the back-end field (column) names have 2 parts - in the case of 'Bank Account Number' - it is called cdm_bankaccountid.cdm_workerbankaccountnumber where cdm_bankaccountid is the column name in the child table and cdm_workerbankaccountnumber is the column name in the parent table.

However I couldn't figure out a way to reference this in the code, I've tried the column name, enclose it with single or double quotes and the code editor keeps saying column not found.

Patch('Worker Bank Accounts',Defaults('Worker Bank Accounts'),
{'cdm_workerid.cdm_workernumber':DataCardValue4.Selected.Text,
cdm_accountidentification:DataCardValue1.Text,
cdm_workerbankaccountnumber:AccountNumberValue.Text});
Patch('Bank Account Disbursements',Defaults('Bank Account Disbursements'),
{'cdm_bankaccountid.cdm_workerbankaccountnumber':AccountNumberValue.Text,
cdm_bankaccountdisbursementnumber:DataCardValue3.Text
'cdm_companyid.cdm_companycode':DataCardValue5.Text});
Arthur Zhu
  • 21
  • 2

0 Answers0