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

Retrieve method does not work in dynamics 365 online (version 9.0)

$
0
0

Here is full code, when i trying to retrieve data. it does not work saying,

d8be1dff-fb39-e811-a833-000d3a33bdbd: Test.Test: Retrieve of contact] (full error file is attached with this thread)(Please visit the site to view this file)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;

namespace Test
{
public class Test : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
throw new NotImplementedException();
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));

// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));

if (context.Depth == 1)
{
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

// Obtain the target entity from the input parmameters.
EntityReference entity = (EntityReference)context.InputParameters["Target"];
//EntityReference entity = (EntityReference)context.OutputParameters["BusinessEntity"];


tracingService.Trace("3 - entity");
var contact = service.Retrieve("contact", entity.Id, new ColumnSet(true));
tracingService.Trace("4 - entity");
if (contact != null)
{
if (contact.Attributes.Contains("address1_name") == false)
{
Random rndgen = new Random();
contact.Attributes.Add("address1_name", "first time value: " + rndgen.Next().ToString());
}
else
{
contact["address1_name"] = "i already exist";
}
service.Update(contact);
}
}
}
}
}


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images