how to pass parameter into fetchxml source in azure data factory

Varagani, Ramana 21 Reputation points
2022-11-17T12:00:31.303+00:00

I have a pipeline with entity as parameter and i want to use this in fetchxml filter query:
<fetch> <entity name="audit">
<attribute name="objectid" />
<attribute name="objecttypecodename" />
<attribute name="objecttypecode" />
<attribute name="action" />
<attribute name="createdon" />
<filter>
<condition attribute="action" operator="eq" value="3" />
</filter>
<filter>
<condition attribute="objecttypecodename" operator="eq" value="@entity"/>
</filter>
<filter>
<condition attribute="createdon" operator="last-x-days" value="48" />
</filter>

<order attribute="createdon" descending="true" />
</entity>
</fetch>

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,517 questions
{count} votes

Accepted answer
  1. MartinJaffer-MSFT 26,021 Reputation points
    2022-11-18T21:24:42.513+00:00

    Hello @Varagani, Ramana ,
    Thanks for the question and using MS Q&A platform.

    If I understand correctly, you have a dynamics / dataverse source dataset, and are using the "Query" option. You have a fetchXML , but you want to parameterize it.

    We can insert pipeline expression into the query as long as it takes the form @{expression} . The curly braces indicate the start/end.

    <filter>  
    <condition attribute="objecttypecodename" operator="eq" value="@entity"/>  
    </filter>  
    

    becomes (assuming your do not want a literal @ in the value)

    <filter>  
    <condition attribute="objecttypecodename" operator="eq" value="@{variables('my_variable_name')}"/>  
    </filter>  
    

    Please do let me if you have any queries.

    Thanks
    Martin


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
      • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Rup Rizal 1 Reputation point
    2022-11-30T16:19:57.557+00:00

    I am working on a ADF data flow that reads out of D365 Account entity using FetchXML. I want to pass a parameter value to the fetchxml query so it pulls only recently modified data.
    <fetch>
    <entity name="account">
    <attribute name="name" />
    <attribute name="primarycontactid" />
    <attribute name="telephone1" />
    <attribute name="accountid" />
    <attribute name="description" />
    <filter type="and">
    <condition attribute="modifiedon" operator="on-or-after" value="[data flow parameter]" />
    </filter>
    </entity>
    </fetch>

    How do I pass dynamic value in [data flow parameter] to the fetxml query? I am passing correct datetime value to the data flow parameter but just not able to use it in FetchXML query.


  2. Rup Rizal 1 Reputation point
    2022-12-05T16:36:13.053+00:00

    This works but it breaks when text is formatted in multiple lines. Seems like it looks for a single line of text so ended up removing line breaks and put text in one line. This makes query unmanageable if it is a complex query with lots of attributes to retrieve.

    Is there option to send formatted text (like above)?