Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

I upload a annotation, but its empty

(0) ShareShare
ReportReport
Posted on by 225

I'm able to create records of entities and want to upload annotations (file attachments) but while the annotation is created and I get the GUID for the annotation, its completely empty holding no data.

I implemented, actually copy & pasted, the code from SDK\SampleCode\CS\BusinessDataModel\Annotation in samples in the SDK. Are there any other tricks to it? As mentioned I get a GUID in return that is a GUID for a empty annotation. 

            Annotation setupAnnotation = new Annotation()
            {
                Subject = "Example Annotation",
                FileName = "ExampleAnnotationAttachment.txt",
                DocumentBody = Convert.ToBase64String(new UnicodeEncoding().GetBytes("Sample Annotation Text")),
                MimeType = "text/plain"
            };

            // Create the Annotation object.
            var guid = _orgService.Create(setupAnnotation);

This should be rather simple, but if I use CRM REST Builder to fetch the annotation with that GUID everything is empty:

filesize: null ,
overriddencreatedon: null ,
objecttypecode: null ,
mimetype: null ,
documentbody: null ,
filename: null ,
notetext: null ,


*This post is locked for comments

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: I upload a annotation, but its empty

    Hi Lars,

    Try using the code below and see if it works.

                Entity note = new Entity("annotation");
                note["subject"] = subject;
                note["filename"] = filename;
                note["documentbody"] = Convert.ToBase64String(data);
                note["objectid"] = new EntityReference("contact",entityId);
                Guid attachmentId = service.Create(note);

    where

    entityId = Guid / ID of the entity in CRM for which we are retrieving the attachments

    subject = Subject of the note that we are creating

    filename = The name of the file we are attaching to note

    data = the content of the file we are attaching to note

    service= CRM organisation service you are connecting to.

    See: http://www.powerobjects.com/2015/01/21/retrieve-and-create-attachments-associated-to-notes-of-an-entity-in-dynamics-crm/

    Hope this helps.

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: I upload a annotation, but its empty

    Working fine for me. Try fetching your annotation like this:

    http://<ORGURL>/api/data/v8.2/annotations(GUID, NO BRACES)

  • Suggested answer
    Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: I upload a annotation, but its empty

    Hi Lars,

    The behavior is odd. Normally if there is an exception, the entire transaction is rolled back and the record is not created at all.

    Where are you getting the GUID from? What table are you querying via the REST request?

    If you try to retrieve the same record, via the Organization.svc Service with all columns, do you see any differences?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans