Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Update an Annotation - How to get the AnnotationId ?

$
0
0

Hello !

I have a custom entity in CRM 2011 Online and there are Annotations attached to the custom entity.

My task is to update some of these Annotations using the SOAP endpoint.

So my idea was to make a QueryExpression and search for the notetext inside the existing Annotations.

After I have found the Annotation inside CRM 2011 Online that match the condition I should be able to get the AnnotationId.

Sadly that don't work and I don't know why, can anybody help me please !

private static Guid GetAnnotationGuid(OrganizationServiceProxy organizationProxy, Entity targetEntity, string suspectString)
{
            Guid RecordId = Guid.Empty;

            string AttributeName = "notetext";
            string ConditionAttributeEquallTo = suspectString;

            try
            {
                QueryExpression query = new QueryExpression("annotation");
                ConditionExpression condition = new ConditionExpression(AttributeName, ConditionOperator.Equal, ConditionAttributeEquallTo);
                FilterExpression filter = new FilterExpression();
                filter.Conditions.Add(condition);
                query.Criteria.AddFilter(filter);
                EntityCollection SearchContactResult = organizationProxy.RetrieveMultiple(query);
                if (SearchContactResult.Entities.Count == 1)
                {
                    foreach (Entity result in SearchContactResult.Entities)
                    {
                        RecordId = result.Id;
                        Console.WriteLine("GetAnnotationID : " + RecordId);
                    }
                }
                else
                    Console.WriteLine("nothing found");
            }
            catch
            {
                throw;
            }
            return RecordId;
}

I already checked out the MSDN but I couldn't find anything useful.

There is an article called "Sample: Upload, Retrieve, and Download an Attachment" about creating an annotation but that didn't help me in any way cause the Annotations are created long time ago and I don't have the possibility to use the annotationId like they do in the example.

Viewing all articles
Browse latest Browse all 8223

Trending Articles



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