locked
how to adding to annotation entity from OrganizationServiceClient in dynamics crm 2011? RRS feed

  • Question

  • Hi All,

    I trying to add annotation from my web service, I use crm service discovery /  OrganizationServiceClient, I used the HelperCode from SDK but I got an error, and can not to compile.

    on below is my codes:

    Annotation anno = new Annotation();
    anno.ObjectId = new Microsoft.Xrm.Sdk.EntityReference() { Id = _headerId, LogicalName = name};
    anno.ObjectTypeCode = name;
    anno.Subject = "Notes From NAV";
    anno.NoteText = reason;
    client.Create(anno);

    please advise.

    thanks

    glo.

    Friday, July 4, 2014 7:00 AM

Answers

  • Hi All,

    this is my solution:

                    Entity note = new Entity();
                    note.LogicalName = "annotation";
    
                    AttributeCollection attrNote = new AttributeCollection();
                    attrNote.Add(new KeyValuePair<string, object>("objectid", new EntityReference() { Id = _headerId, LogicalName = name }));
                    //for adding note/annnotation to custom entity, no need set value to objecttypecode!!. - dp
                    //attrNote.Add(new KeyValuePair<string, object>("objecttypecode", new OptionSetValue() { Value = 10399 }));
                    attrNote.Add(new KeyValuePair<string, object>("subject", "Notes From NAV"));
                    attrNote.Add(new KeyValuePair<string, object>("notetext", reason));
                    note.Attributes = attrNote;
                    client.Create(note);

    I remark "objecttypecode" attribute and it works.

    thanks all.

    • Marked as answer by pntr Monday, July 7, 2014 6:09 AM
    Monday, July 7, 2014 6:09 AM

All replies

  • Hi,

    Make sure _headerId is actually of type Guid and name is of type string. What is the exact error you're getting during compile time?


    Admin QuikView Solution for CRM 2013

    Friday, July 4, 2014 7:09 AM
  • Hi pntr,

    Can you tell us what is the error?

    Saludos


    Salu2 Atilin | http://www.dexrm.com

    Friday, July 4, 2014 7:17 AM
  • Hi All,

    this is my solution:

                    Entity note = new Entity();
                    note.LogicalName = "annotation";
    
                    AttributeCollection attrNote = new AttributeCollection();
                    attrNote.Add(new KeyValuePair<string, object>("objectid", new EntityReference() { Id = _headerId, LogicalName = name }));
                    //for adding note/annnotation to custom entity, no need set value to objecttypecode!!. - dp
                    //attrNote.Add(new KeyValuePair<string, object>("objecttypecode", new OptionSetValue() { Value = 10399 }));
                    attrNote.Add(new KeyValuePair<string, object>("subject", "Notes From NAV"));
                    attrNote.Add(new KeyValuePair<string, object>("notetext", reason));
                    note.Attributes = attrNote;
                    client.Create(note);

    I remark "objecttypecode" attribute and it works.

    thanks all.

    • Marked as answer by pntr Monday, July 7, 2014 6:09 AM
    Monday, July 7, 2014 6:09 AM