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

How to retrieve the current value of the description field in Dynamics 365 Activity Task record?

$
0
0

I have a Dynamics 365 Activity Task record that contains a description with the value "Test Description Value". I want to retrieve this value in a plug-in.  My main code is outlined below.

    public void Execute(IServiceProvider serviceProvider)
            {
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService((typeof(IPluginExecutionContext)));
                IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = factory.CreateOrganizationService(context.UserId);
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService)); if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity task = (Entity)context.InputParameters["Target"]; if (task.LogicalName == "task") { ColumnSet cs = new ColumnSet(new string[] { "description", "ownerid" }); service.Retrieve("task", task.Id, cs); foreach (KeyValuePair<String, Object> attribute in task.Attributes) { tracingService.Trace(attribute.Key + ": " + attribute.Value); } } } }

Iterating the foreach loop reveals that the task.Attributes does not contain a key for description, nor can I get the current value of the description using task["description"]. Both return a System.Collections.Generic.KeyNotFoundException.

Is it possible to get the current value of the description field of an Activity Task record in a plug-in?

How?


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images