We have recently encountered an issue with GP 2015 R2 in the Document Attachment functionality, the case has been reported by various community members such as this case.
Users are not able neither to attach documents or to view attached documents. The issue is related to all Dynamics GP users except for 'sa' specifically, regardless of the security roles granted to the users.
When attaching a new document, the systems responds with an error stating that "A Save Operation on table 'coAttachMSTR' has created a duplicate key error"
When a user tries to preview already attached documents, the systems responds with an error message stating that "Unable to preview this attachment"
|Error previewing Attached Documents|
Tracking this error on the SQL profilers shows that this is mostly a dysfunctional issue related to all users other than 'sa', and the reason is not security since granting any of the users a "Sys Admin" just for the sake of testing doesn't resolve the issue.
As retrieved from the SQL profiler, the 'sa' user is getting the attachment ID properly, and then getting it inserted into the CO00100 (procedure zDP_CO00101SI ),
-- The code below is retrieving the Attachment ID
EXEC sp_executesql N'INSERT INTO coAttachmentItems (Attachment_ID, fileName, BinaryBlob) VALUES (@Attachment_ID, @fileName, 0x0) ',
N'@Attachment_ID nvarchar(36),@fileName nvarchar(6)',
@Attachment_ID = N'7e063e4d-4d5c-4c14-9337-70d0a15a337a',
@fileName = N'12.mac'
-- The code below is inserting the record into CO00100 including the attachmentID
DECLARE @num INT
EXEC FIVER.dbo.zDP_CO00101SI '7e063e4d-4d5c-4c14-9337-70d0a15a337a',
'12.mac', '', 'sa', '2017.04.12', '03:12:37', 'IC', 0, 0, 0, '', 0,
0, @num OUT
On the other hand, the other test user is not retrieving any attachmentID, and the field is blank as shown below:
DECLARE @num INT
EXEC FIVER.dbo.zDP_CO00101SI '', '12.mac', '', 'USER15', '2017.04.12',
'03:07:48', 'IC', 0, 0, 0, '', 0, 0, @num OUT
As you see, the first parameter which is the AttachmentID is blank, and that's why the error is popping on the screen.
The case is currently reported to Microsoft support team on MSConnect and it has been marked as "Tracking", any further official responses will be provided immediately on this post. Meanwhile, you may review the report on MSConnect on this link
Mahmoud M. AlSaadi