Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

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

$
0
0

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.


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>