cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ajludlow
Frequent Visitor

Delete a row in SQL Server when Corresponding row in Dynamics 365 has been Deleted

I've created a flow that has a Dynamics 365 trigger for When a record is deleted, the Action off the back of this is SQL Server Delete row V2. 

 

When a row is then deleted from the contact entity in Dynamics 365 it attempts to delete the corresponding row in SQL. The error I get back is Resource not found, status code 404.

 

I understand the Row ID parameter on the SQL delete needs to be a primary key in the SQL table, which it is. The data type is set to a unique identifier too. With the Row ID set to Dynamic content and the ContactID field selected. I know there are two different contact id fields but I'm definitely selecting the same field as I'm using for an Insert using dynamics trigger and SQL Insert. 

 

All I'm using is the standard GUI on the flow site so I dont see how I can be going wrong, however I cant seem to find a way around the error, any suggestions more than welcome

2 REPLIES 2
yashag2255
Dual Super User II
Dual Super User II

Hey @ajludlow 

 

The when an item is deleted trigger, returns only the GUID of that particular record that is deleted. So, this record should exist in the SQL table too inorder to retrieve and identify the row that needs to be deleted. You can probably add a row to the SQL table named as rowidind365 and whenever a record is created in that entity in D365, setup a flow to copy the GUID of that record and update the row in SQL. That way, when the item gets deleted, it will be better to compare the GUID row and delete the corresponding item (makes sense?)

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Hi @yashag2255 

 

Thanks for the reply, for the Delete trigger I'm already using the contactid field from D365, which is the unique GUID for the record. I'm also using this same field for another flow that creates an entry in the same SQL table, with the field named as ContactID, this field is also set as the primary key on the SQL table. With that in mind it should already be comparing like for like on the same field?

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Top Solution Authors
Top Kudoed Authors
Users online (2,012)