I have 2 Attachment fields MyDocs and CustDocs on a page type. I have transforms setup that display them and setup the proper links to them and everything. The issue I am running into is when I delete them they still show up on the form tab of the page. This causes a problem because when a new version of the page is created it adds all the documents listed there despite one having been deleted.
I started to dig into the SQL a bit to see if I could reverse engineer whats happening. The CMS_Attachment record is being deleted but none of the history records.
The query it uses to populate the admin form as far as I can tell is:
WITH AllData AS
SELECT [AttachmentHistoryID], [AttachmentGUID], [AttachmentImageWidth], [AttachmentImageHeight], [AttachmentExtension], [AttachmentName], [AttachmentSize], [AttachmentOrder], [AttachmentTitle], [AttachmentDescription], ROW_NUMBER() OVER (ORDER BY [AttachmentOrder], [AttachmentName], [AttachmentHistoryID]) AS [CMS_RN]
WHERE ([AttachmentHistoryID] IN (
WHERE [VersionHistoryID] = @VersionHistoryID
)) AND ([AttachmentGroupGUID] = @AttachmentGroupGUID)
SELECT *, (SELECT COUNT(*) FROM AllData) AS [CMS_TOT]
WHERE CMS_RN BETWEEN 1 AND 5
ORDER BY CMS_RN
So, it's focused on the history as opposed to the current state. I've tried the following 2 urls for deleting the attachment.
Both of them remove the attachment but none of the history so they still show up. What am I doing wrong? Also just in general can anybody point me to some resources on working with the rest api with attachments. They seem to behave differently than the rest of the api. I've come across https://bitwizards.com/blog/august-2013/retrieving-attachment-info-using-the-kentico-res, https://docs.kentico.com/display/API9/Attachments, and https://docs.kentico.com/display/K9/Manipulating+data+using+REST#ManipulatingdatausingREST-Uploadingattachmentfiles and did my best from there.