When using the Xrm.Navigation.navigateTo function to create a new entity record, I face the following problem: the return value savedEntityReference is null when data records are merged using duplicate detection.
So if a new data record is created, you get it back. If the window is closed without saving, the value is null. If a duplicate is detected and the records are merged, the value is also null.
If a duplicate was merged, I would like to get the ID of the "new" record. Regardless of whether a new data record has been created or a suitable one already exists, I would like to continue working with the corresponding ID.
Thank you for your help and best regards
If I understand correctly, are you looking to redirect the user to the master record if a record that they open has been merged with another record?
If that's correct, then you could perform a webapi query to retrieve the master id value of the record that the user is currently viewing, and then redirect the user to that record id if it has been populated. This redirect could happen multiple times though, if the master record has been merged again with another master record, and this merge action repeated again
I'll try to explain my scenario and what I want to achieve:
I have the "customer request" entity. A record is created in this table via a custom connector for each customer request on my website. The customer provides his first and last name on the website. Now I want to create a new record in my customer table via a ribbon button on the top of the customer request form. To do this, I open the corresponding customer form with "Xrm.Navigation.navigateTo", which I already prefill with the first and last name. When the user saves the customer's record, I get the customer's GUID back and can write it to the "customer" lookup field of the "customer request" entity. However, if the duplicate detection takes effect and the user merges the "new" customer with an existing customer, I get nothing back and cannot fill the lookup field.
So now I have to somehow get the GUID of the already existing dataset. Unfortunately, the record is never opened to access the GUID.
I would suggest looking at having a plugin that would trigger on the merge (or create/update as I would assume D365 would update the master id in the background or possibly add the master id to the target entity just before it would be created in D365) of the customer record.
From the merge trigger you would have access to the original duplicate record being created and the master record it was being merged to, and you could also still get access to the original customer request entity so you could update it in the background with the final customer record.
If the merge didn't fire you could then still register another plugin on the create of the customer record to update your customer request record accordingly
Keep up to date with current events and community announcements in the Power Apps community.
A great place where you can stay up to date with community calls and interact with the speakers.
Check out the latest Community Blog from the community!