Hello all...I am retrieving to retrieve data from another form however I am always getting error as Invalid xml
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
namespace Plugin3
{
public class lookup:IPlugin
{
string playerName;
string jerseyno;
public void Execute(IServiceProvider serviceprovide)
{
try
{
IPluginExecutionContext ex = (IPluginExecutionContext)serviceprovide.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory servicefactory = (IOrganizationServiceFactory)serviceprovide.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = (IOrganizationService)servicefactory.CreateOrganizationService(ex.UserId);
ITracingService Tracingservice = (ITracingService)serviceprovide.GetService(typeof(ITracingService));
if (ex.InputParameters.Contains("Target") && ex.InputParameters["Target"] is Entity)
{
Tracingservice.Trace("tracing strated");
Entity entity = (Entity)ex.InputParameters["Target"];
if (entity.LogicalName == "ccs_jersey")
{
if (entity.Attributes.Contains("ccs_jerseno"))
{
Tracingservice.Trace(jerseyno = entity.GetAttributeValue<String>("ccs_jerseyno"));
}
String player = Getname(service, jerseyno,Tracingservice);
Entity jersey = new Entity("ccs_jersey");
jersey.Id = entity.Id;
jersey.Attributes["ccs_playername"] = playerName;
service.Update(jersey);
}
}
}
catch (Exception ex) { throw new InvalidPluginExecutionException("Error" + ex.Message);}
}
public String Getname(IOrganizationService service,string jerseyno,ITracingService tracingservice)
{
try
{
tracingservice.Trace("xml execution");
string fecthxml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='ccs_information'>" +
"<attribute name='ccs_informationid'/>" +
" <attribute name='ccs_name'/>" +
"<attribute name='createdon'/>" +
"<order attribute='ccs_name' descending='false'/>" +
"<filter type='and'>" +
" <condition attribute='ccs_jersey' operator='eq' value="+ jerseyno+ "/>" +
" </filter></entity></fetch>";
tracingservice.Trace("bhbg");
EntityCollection playername = service.RetrieveMultiple(new FetchExpression(fecthxml));
{
if (playername.Entities.Count > 0)
{
if (playername.Entities[0].Attributes.Contains("ccs_name"))
{
tracingservice.Trace(playerName = playername.Entities[0].GetAttributeValue<String>("ccs_name"));
}
else
{
throw new Exception("please enter the player namae");
}
}
return playerName;
}
}
catch (Exception ex) { throw new InvalidPluginExecutionException("Error in city" + ex.Message); }
}
}
}