Menu

Exporting Annotation (Note) Attachment

A requirement I had recently was to move data between CRM environments, some of this data was files loaded into CRM as an attachment to an annotation (note). I’ve included a snippet below which has been cut down to bare bones. Its basically a function that uses fetch xml to retrieve the annotations, decode the file data and save to disk. So each annotation record has three attributes which are important here;

filename – name of the file (note: different from the subject of the annotation)

documentbody – Base64 encoded string which represents the document – hence I decode it before writing to disk

mimetype – I don’t actually use it for anything in the snippet but its required for reimporting – its an internet mime type and describes the type of file, e.g. image/jpeg

If you are going to use this you will probably want to change the fetch to; get more records (count) and have some filtering, i used a link-entity, e.g. get attachments regarding contacts