Thursday, June 4, 2009

Attach Notes to Contact / Account in CRM

public Guid InsertNotesForContact(string contactid, string body)
{
CrmService service = new CrmService();
service = MyService();
annotation note = new annotation();
//#2
//note.ownerid = new Owner();
//note.ownerid.type = "systemuser";
//note.ownerid.Value = new Guid("000-000-0000"); <-- don't use this value
//note.ownerid.name = "Administrator";
//#3
note.objectid = new Lookup();
// note.objectid.name = "contact name";
note.objectid.type = EntityName.contact.ToString();
note.objectid.Value = new Guid(contactid);
note.notetext = body;
//note.subject = "my attachment";
//#4
note.objecttypecode = new EntityNameReference();
note.objecttypecode.Value = EntityName.contact.ToString();
Guid newNoteID = service.Create(note);
return newNoteID;
}

No comments: