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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Getting the Invalid XML error as attached the XML through code activity.

(0) ShareShare
ReportReport
Posted on by

<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>
<entity name='aes_subproject'>
<attribute name='aes_subprojectid'/>
<attribute name='aes_name'/>
<attribute name='createdon'/>
<attribute name='aes_subnumber_subproject'/>
<order descending='false' attribute='aes_name'/>
<filter type='and'>
<condition attribute='aes_subnumber_subproject' operator='not-null'/>
</filter>
<link-entity name='opportunity' alias='ad' link-type='inner' to='aes_opportunyid' from='opportunityid'>
<filter type='and'>
<condition attribute='opportunityid' operator='eq' value='" + objTarget.Id + @"' uitype='opportunity' uiname=''/>
</filter >
</link-entity>
</entity >
</fetch >

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello Rahul,

    There are no mistakes that I can see in the part of code you provided. Can you please post the full code?

  • Joana Pinto Profile Picture
    740 on at

    Hi,

    I don't see anything wrong with this fetch... so my guess is that the error is in the condition tag, with the dynamic value. Can you show us the XML in the end, after placing the dynamic value? (the objTarget.Id) to check if that GUID is in the correct format.

  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at

    Looks like you have missed here ' symbol in expression. Please use below format and try again.

    condition attribute='opportunityid' operator='eq' uitype='opportunity' value=" + "'" + objTarget.Id + "'" + @"/>

  • Community Member Profile Picture
    on at

    Hello Andrew,

    This is the code which I am using.

    Thanks in advance.

    public class ConcatenateSubnumber : CodeActivity

       {

           protected override void Execute(CodeActivityContext context)

           {

               ITracingService tracingService = context.GetExtension<ITracingService>();

               IWorkflowContext workflowContext = context.GetExtension<IWorkflowContext>();

               if (workflowContext == null)

               {

                   tracingService.Trace("Cheking the condition for workflow");

                   throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");

               }

               IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();

               IOrganizationService service = serviceFactory.CreateOrganizationService(workflowContext.UserId);

               try

               {

                   if (workflowContext.InputParameters.Contains("Target") && workflowContext.InputParameters["Target"] is Entity)

                   {

                       Entity objTarget = (Entity)workflowContext.InputParameters["Target"];

                       String fetchXmlString = @"<fetch distinct = 'false' mapping = 'logical' output-format = 'xml-platform' version = '1.0'>

                                               <entity name='aes_subproject'>

                                               <attribute name='aes_subprojectid'/>

                                               <attribute name='aes_name'/>

                                               <attribute name='createdon'/>

                                               <attribute name='aes_subnumber_subproject'/>

                                               <order descending='false' attribute = 'aes_name'/>

                                               <filter type='and'>

                                               <condition attribute='aes_subnumber_subproject' operator='not-null'/>

                                               </filter>

                                               <link-entity name='opportunity' alias='ad' link-type='inner' to='aes_opportunyid' from='opportunityid'>

                                               <filter type='and'>

                                               <condition attribute='opportunityid' operator='eq' value= "+ "'" + objTarget.Id.ToString() + "'" +  @"' uitype='opportunity' uiname=''/>

                                               </filter>

                                               </link-entity>

                                               </entity>

                                               </fetch>";

                       EntityCollection subProjectrecords = service.RetrieveMultiple(new FetchExpression(fetchXmlString));

                       throw new InvalidPluginExecutionException("after subprojectrecords");

                       if ((EntityCollection)subProjectrecords != null)

                       {

                           updateRecord(subProjectrecords, objTarget, tracingService, service);

                       }

                   }

               }

               catch (Exception ex)

               {

                   throw new FaultException(ex.Message);

               }

           }

    }

  • Community Member Profile Picture
    on at

    Hello Joana,

    Below is the XML which I am using from Advanced find.

    <?xml version="1.0"?>

    <fetch output-format="xml-platform" distinct="false" version="1.0" mapping="logical">

    <entity name="aes_subproject">

    <attribute name="aes_subprojectid"/>

    <attribute name="aes_name"/>

    <attribute name="createdon"/>

    <order attribute="aes_name" descending="false"/>

    <filter type="and">

    <condition attribute="aes_subnumber_subproject" operator="not-null"/>

    </filter>

    <link-entity name="opportunity" link-type="inner" alias="af" from="opportunityid" to="aes_opportunyid">

    <filter type="and">

    <condition attribute="opportunityid" operator="eq" uiname="Testing" uitype="opportunity" value="{D9D71E20-0C1E-E911-A960-000D3A3A14C1}"/>

    </filter>

    </link-entity>

    </entity>

    </fetch>

    Thanks in advance

  • Community Member Profile Picture
    on at

    Hello Pravin,

    I tried with your suggested answer but still geting the same error.

    Thanks iin advance

    Regards,

    Rahul Jambhulkar

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 96 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans