web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Getting blank Document body while retrieving the values using fetch, QueryExpression.

(0) ShareShare
ReportReport
Posted on by 15

Trying to clone an annotation record in CRM however, while cloning facing an issue in copying Documentbody. Getting document body as null while retrieving it through QueryExpression/Fetch. Steps tried-

1. Retrieving all attributes of annotation record basis objectid -  Got document body as null.

2. Retrieve documentbody basis annotationid - Still no luck.

PS

Annotation Records are getting created, attachment is also attached but document body is of 0 bytes.

*This post is locked for comments

I have the same question (0)
  • Radu Chiribelea Profile Picture
    6,667 on at

    Hello,

    Does this happen for only one annotation or all of them?

    What CRM Build are you one? Is this CRM Online or OnPremise?

    Regards,

    Radu

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Hi

    Annotation (Notes) entity does not have to have the document body all the time, it will only be having data when there is an attachment.

    I would check the value of Is Document flag on annotation entity.

    if the Is Document flag is true and if the File Name fields contain data then only the document body will have data

    ScreenClip-_5B00_213_5D00_.png

    And when you clone, make sure you only set the value to new record if the field has value otherwise you will get an error complaining the documentbody does not exist or something similar

    Instead of cloning the whole object, i would suggest you could only copy the attributes you need and there aren't many anyway, please see below

    var note= results.Entities.First(); // This is the original or source note


    Entity Annotation = new Entity("annotation");
    Annotation.Attributes["objecttypecode"] = note.Attributes["objecttypecode"];  // Change it if  you are attaching to different entity / record
    Annotation.Attributes["objectid"] =note.Attributes["objectid"] ;
    if (note.Attributes.Contains("subject"))
    Annotation.Attributes["subject"] = note["subject"];
    if (note.Attributes.Contains("documentbody"))
    Annotation.Attributes["documentbody"] = note["documentbody"];

    if (note.Attributes.Contains("mimetype"))
    Annotation.Attributes["mimetype"] = note.Attributes["mimetype"];

    if (note.Attributes.Contains("notetext"))
    Annotation.Attributes["notetext"] = note.Attributes["notetext"];

    if (note.Attributes.Contains("filename"))
    Annotation.Attributes["filename"] = note.Attributes["filename"];

    crmService.Create(Annotation); 

    Hope this helps

  • Ayushi Sharma Profile Picture
    15 on at

    Not for all the docs. We are using 9.0 version of

    dynamics 365 crm online.

  • Ayushi Sharma Profile Picture
    15 on at

    Not getting the documentbody for the notes having "Is document" field as "No". Despite having attachment attached to it.

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Could you do an advance find query and see the columns value for IS Document and File Name for the same note that you are getting null in your plugin please?

  • Ayushi Sharma Profile Picture
    15 on at

    Yes I checked. The Is document flag is no for these files.

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    I think that means the document not uploaded.  When you open the note record i assume you only get the notes and attachment area is empty?

    Whats the size of the attachment? is it only for some notes you are having this issue or does it happen to all notes with attachment?

  • Ayushi Sharma Profile Picture
    15 on at

    There is an attachment in the record. If I tries to open it opens however, when I try to retrieve it for cloning, I don't get the body. When I try to hit it with web API it returns the documentbody.

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Could you share any screenshots or your code that tries to retrieve?

  • Suggested answer
    CU13121614-0 Profile Picture
    on at

    Hi,

    I just faced the exact same issue.

    Retrieve multiple will not retrieve large field values (this makes sense as many records will take too long to retrieve).

    What I had to do was just retrieve the id from retrieve multiple, then do a retrieve on this to get the document body :-)

    This was no problem for me as i was only dealing with one result.

    Regards

    Chris

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans