Has anyone tried to use the CDS to Patch into the OOB Addresses entity?
I'm not sure how to target the parent Contact record.
The PowerApps is launched using a button and some JavaScript from Dynamics that passes the GUID of the Contact.
When the PowerApp launches it creates a Collection using the current address information.
The user then updates the address 1 fields on the Contact using a form in the PowerApp. They hit submit which uses a simple SubmitForm to update the Contact. OnSuccess of that form submission, the code below runs to Patch the Addresses entity with the old address information.
You'll notice I have three lines commented out. Originally this was built using the Dynamics 365 connector that is not available in the GCC - we're working to migrate this app to the GCC. With these lines commented out it successfully creates the new address record, but it's not tied to the Contact.
Any help is appreciated!
Code below:
ForAll(ContactInfoBefore,
Patch([@Addresses],
Defaults([@Addresses]),
{
//_parentid_type: "contacts",
//parentid: contactid,
//addresstypecode: address1_addresstypecode,
primarycontactname: address1_primarycontactname,
line1: address1_line1,
line2: address1_line2,
city: address1_city,
stateorprovince: address1_stateorprovince,
country: address1_country,
county: address1_county,
postalcode: address1_postalcode,
po_status: 'Status (Addresses)'.Previous,
po_startdate: po_address1startdate,
po_enddate: DateAdd(
Now(),
23,
Hours
)
}
)
);