web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Invalid xml...

(0) ShareShare
ReportReport
Posted on by

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); }

}

}

}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    anilambadan Profile Picture
    1,160 on at

    Please try to format the fetchxml like

    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='{0}'/>

                                       </filter>

                                   </entity>

                               </fetch>";

               EntityCollection playername = service.RetrieveMultiple(new FetchExpression(string.Format(fecthxml, jerseyno)));

  • Community Member Profile Picture
    on at

    It worked..Thx a lot

  • Community Member Profile Picture
    on at

    你可以试试用QueryExpression 来实现。就不会报错了。FetchExpression对特殊字符很敏感,比如或者符号。

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans