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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

External CRM project and I am trying to link a note/annotation to an incident.

(0) ShareShare
ReportReport
Posted on by

I have an external CRM project and I am trying to link a note/annotation to an incident.

I receive the following error when trying to create the annotation:
System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]:
objectid (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).

The error doesn't give much indication of what has gone wrong.

The code is as follows:
// I create the Incident here, which creates successfully
Guid newIncidentGuid = _service.Create(newIncidentEntity);

string ext = @System.IO.Path.GetFullPath(this.FU1.PostedFile.FileName);

if (ext != "")
{
 FU1.SaveAs(@"c:\temp\" + @System.IO.Path.GetFileName(this.FU1.PostedFile.FileName));

 Microsoft.Xrm.Sdk.Entity newNoteEntity = new Microsoft.Xrm.Sdk.Entity("annotation");
 newNoteEntity["subject"] = "Picture 1";
 newNoteEntity["filename"] = @System.IO.Path.GetFileName(this.FU1.PostedFile.FileName);
 newNoteEntity["mimetype"] = "image/jpeg";
 string encodedData = string.Empty;

 using (FileStream fs = new FileStream(@"c:\temp\" + @System.IO.Path.GetFileName(this.FU1.PostedFile.FileName), FileMode.Open, FileAccess.Read))
 {
  byte[] byteData = new byte[fs.Length];
  fs.Read(byteData, 0, byteData.Length);
  encodedData = System.Convert.ToBase64String(byteData);
 }

 newNoteEntity["documentbody"] = encodedData;
 newNoteEntity["objectid"] = new Microsoft.Xrm.Sdk.EntityReference("incident", newIncidentGuid);

 Guid annotationId = _service.Create(newNoteEntity);
}

I have tried to include the "ObjectTypeCode" being equal to "incident", but to no avail.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Alagunellaikumar Profile Picture
    6,212 on at

    Hi

    Your code is correct. You please try to use the below code and check notes added or not.

    Entity Annotation = new Entity("annotation");

    Annotation.Attributes["subject"] = "Demo Note 7";

    Annotation.Attributes["documentbody"] = str;

    Annotation.Attributes["mimetype"] = @"application/text";

    Annotation.Attributes["notetext"] = "Sample attachment 7";

    _serviceProxy.Create(Annotation);

  • Community Member Profile Picture
    on at

    Hi,

    Thank you for assisting.

    Without the attachment the Note is created successfully.

    I have come across another issue though, after migrating the organization from CRM 2011 to CRM 2013 all entity forms seem to be read only. The error message is as follows;<Message>error : /%000%7D/WebResources/msdyn_/CrmSoapServiceProxy.js</Message>. I am not sure if the issues could be related so i am busy creating a new organization to test my external project and adding an attachment again.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans