locked
Cannot Create Attachment Record RRS feed

  • Question

  • I am trying to copy emails including attachments from one CRM deployment to another CRM deployment. To do so I am trying to copy all the records of entity 'attachment' using SSIS/Kingway Soft. However, I am getting the error:

    The 'Create' method does not support entities of type 'attachment'.

    How can I copy/create these 'attachment' records?

    Thursday, October 29, 2015 3:27 AM

Answers

  • When creating records you should create records of type activitymimeattachment, and CRM will create the corresponding attachment record - you cannot directly create a record of type attachment.

    What operation are you doing when you get the error 'activitymimeattachment With Id = ... Does Not Exist' ? It shouldn't be possible to get this error on a create of activitymimeattachment.


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Marked as answer by hfaun Monday, November 2, 2015 1:02 AM
    Friday, October 30, 2015 10:55 PM
    Moderator

All replies

  • Hi,

    I guess you need to use entity 'activitymimeattachment' for this..

    Please try this entity and see if this works...


    MayankP
    My Blog
    Follow Me on Twitter

    Thursday, October 29, 2015 10:30 AM
    Answerer
  • MayankP, copying the 'activitymimeattachment' is actually the first thing I tried. However, that gave me the error:

    CRM service call returned an error: activitymimeattachment With Id = ... Does Not Exist

    After that I did look further into email attachments. It appears that the info about the attachment is stored in 'activitymimeattachment'. However, the actual attachment seems to be stored in 'attachment'. By doing so, if the same attachment is used multiple times only one copy needs to be stored. Interestingly, if you use the SDK the whole attachment incl. payload/data is created by 'activitymimeattachment'. I guess, internally it is later broken down into two pieces. When I search the database I can actually see the link from the 'attachment' record to the 'activitymimeattachment' record.

    At the end my goal is simply to copy emails with attachments. Any ideas how to do it is appreciated.

    Thursday, October 29, 2015 2:13 PM
  • Hi,

    My guess is that when you are copying this using SSIS/Kingway Soft for activitymimeattachment you might have mapped attachmentid or attachementnumber attribute hence may be it is failing. Try to remove mapping for attachmentid and try again.

    Other option is for you to write C# code which uses SDK API calls to migerated email attachement fron one environment to another, some example code related this can be found in following article

    http://www.mscrmconsultant.com/2012/05/create-update-retrieve-email-attachment.html

    Hope this helps



    MayankP
    My Blog
    Follow Me on Twitter

    Friday, October 30, 2015 1:52 PM
    Answerer
  • When creating records you should create records of type activitymimeattachment, and CRM will create the corresponding attachment record - you cannot directly create a record of type attachment.

    What operation are you doing when you get the error 'activitymimeattachment With Id = ... Does Not Exist' ? It shouldn't be possible to get this error on a create of activitymimeattachment.


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Marked as answer by hfaun Monday, November 2, 2015 1:02 AM
    Friday, October 30, 2015 10:55 PM
    Moderator
  • I have only tried to copy attachment records when copying activitymimeattachment records didn't work. Initially, I did have all fields mapped expect for activityid and attachmentid (this are the default settings). Based on MayankP's input I also unmapped attachementnumber. However, I still get the same error, i.e. activitymimeattachment With Id = ... Does Not Exist. Interestingly, it complains about the id (I assume) of the record I am trying to copy.
    Friday, October 30, 2015 11:01 PM
  • Your problem might be with activitymimeattachmentidunique, which I think is best unmapped. Have you kept the primary key values for the related records - e.g. the email ?

    From the id in the error message you should be able to work out which field is causing the problem


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Saturday, October 31, 2015 11:41 AM
    Moderator
  • Thanks for all the input. After a lot more time of trying from your input and google I finally just deleted everything related to emails and recreated it. It is working now. I am not quite sure where the issue came from but I have a feeling it was somewhere in my error processing path.

    Btw, I ran into another 'problem'. Some emails were in pending send status. Due to that status I could not associate the attachment with the email (I first create the emails and then the attachments). So when creating the email I did ignore the two status fields and then update them after the attachments were created.

    Monday, November 2, 2015 1:02 AM