locked
How to retrieve a note with its filename ? RRS feed

  • Question

  • Hello,
    I am programatically attaching notes of types (doc,pdf,xls,image) to a custom entity and I need to check first whether this note filename already exists on this entity or not.

    I'm using this code:

    public static Boolean AnnotationExists(string filename)
            {
    
                _service = new CRMSer.OrganizationServiceClient();
    
                QueryByAttribute query = new QueryByAttribute();
                query.EntityName = "annotation";
                ColumnSet cset = new ColumnSet();
                cset.AllColumns = true;
                cset.Columns = new string[] { "true" };
                query.ColumnSet = cset;
                query.Attributes = new string[] { "filename" };
                query.Values = new object[] { filename };
    
                EntityCollection result = (EntityCollection)_service.RetrieveMultiple(query);
                if (result.Entities.Length > 0)
                {
    
                    return true;
                }
                else
                    return false;
    
            }

    But this threw an exception that the resulting message size was exceeding the limit although i'm only expecting a single entity to be returned.

    Can you please help me with what i'm doing wrong ?

    Thanks,
    • Edited by SB User Sunday, January 12, 2014 2:09 PM
    Sunday, January 12, 2014 2:08 PM

Answers

  • I changed the columnset instead of retrieving all columns, I only set it to get "filename", this way the message size wasn't exceeded.
    • Marked as answer by SB User Sunday, January 12, 2014 3:28 PM
    Sunday, January 12, 2014 3:28 PM