While using Dataverse connector [formerly known as Common Data Service (Current Environment) connector] for different operations, List Rows is one of the common Actions we use in Flow implementations with Dataverse.
If using FetchXML Query as filter is your choice, there one of the most common issues with an XML is having an Invalid XML due to the special characters in the data we are passing.
Many times, this issue goes unidentified since we end up checking only syntax!
Here’s what you can also add as an additional check to escape the special character scenario in FetchXML query in a List Rows action.
Invalid XML Issue – Special Character
Let’s look at one of the common examples where you’ll see this error on runtime when a FetchXML issue appears
- You have a Flow wherein you are using FetchXML query to list records in Dataverse connector using List Records action.
- But when happens is, when this Flow Runs, it results in an error on the List Records step.
- And if you look at the right hand pane for the error, it could be a Invalid XML error which you would get in Dataverse (or while working in Dynamics CRM if you have experienced in the past).
- So, let’s look at what could be wrong in this case among several other reason of using FetchXML and getting syntactical errors.
If you look at my XML below, it looks like there could be some parameters that have special characters in them and hence, your XML might fail if not anything else.
Let’s look at how we can resolve the same.
As a solution to this, you can use the encodeURIComponent function in Flow to counter this problem –
- Now, in ideal cases, you parameters could be coming in from elsewhere which you would add in the FetchXML as parameters.
Let me store the same in a sample String Variable for now.
In the Value, I’ll look for an expression called as encodeUriComponent()
- Then, I simply enter the value which I’ll pass on to the Fetch XML filter to be used later on. And then I enter the value in the function.
And it looks like this in your variable.
- Now, you just pass this on to the Fetch XML itself.
- And now, this should work successfully
Here’ is the Microsoft Docs of the function to encore URI and help streamline special characters – https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#encodeUriComponent?WT.mc_id=DX-MVP-5003911
Hope this was helpful!
Here are some Power Automate posts you might want to check –
- FetchXML Aggregation in a Flow using CDS (Current Environment) connector | Power Automate
- Invalid type. Expected Integer but got Number error in Parse JSON – Error at runtime after generating Schema | Power Automate
- Asynchronous HTTP Response from a Flow | Power Automate
- Validate JSON Schema for HTTP Request trigger in a Flow and send Response | Power Automate
- Converting JSON to XML and XML to JSON in a Flow | Power Automate
- Office 365 Outlook connector in Cloud Flows showing Invalid Connection error | Power Automate
- FormatDateTime function in a Flow | Power Automate
- Trigger Conditions not working in a Cloud Flow? Here’s Why | Power Automate Quick Tip
- Read OptionSet Labels from CDS/Dataverse Triggers or Action Steps in a Flow | Power Automate
- InvalidWorkflowTriggerName or InvalidWorkflowRunActionName error in saving Cloud Flows | Power Automate Quick Tip