Featured Post

Dynamics GP 2018 is now Released

It is officially published that Microsoft Dynamics GP 2018 is available, the download link is provided below: Product download page ...

Wednesday, July 8, 2015

Document Attachment Error with GP 2015 R2 - "A Save Operation on table 'coAttachMSTR' has created a duplicate key error"


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.
Symptoms
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"
 
Save Operation Error when Attaching Documents

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


Technical Perspective 
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'
go
    
-- The code below is inserting the record into CO00100 including the attachmentID    
BEGIN
    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
    SELECT  @num
END


On the other hand, the other test user is not retrieving any attachmentID, and the field is blank as shown below:

BEGIN
    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
    SELECT  @num
END

As you see, the first parameter which is the AttachmentID is blank, and that's why the error is popping on the screen.

Solution

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


Best Regards, 
Mahmoud M. AlSaadi



3 comments:

  1. Hi Mahmoud,

    Any update for above reported issue from Microsoft?

    ReplyDelete
    Replies
    1. Hello Soma
      This has been resolved with the most recent release (july Hotfix Round 2), further details can be found on:
      http://mahmoudsaadi.blogspot.com/2015/08/document-attachment-error-with-gp-2015.html


      Best Regards,
      Mahmoud M. AlSaadi

      Delete
    2. Yes. Mahmood.

      This has been resolved by updating latest hot fix (804). Yesterday I have updated and confirmed.

      Thanks

      Delete