Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Nullable fetch XML (or If statment) problem !

Posted on by 15

Hi everybody,

I am destroying my toots on a problem that is maybe not so complex, but I want to be sure that I can't do it directly in my XML before implementing some kind of power automated workaround.

I have this kind of fetch XML query in my flow:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="bd_iccicase">
<attribute name="bd_iccicaseid" />
<attribute name="bd_name" />
<attribute name="createdon" />
<order attribute="bd_name" descending="false" />
<filter type="and">
<filter type="or">
<filter type="and">
<condition attribute="bd_name" operator="eq" value="@{triggerOutputs()?['body/bd_name']}" />
<condition attribute="bd_lastname" operator="eq" value="@{triggerOutputs()?['body/bd_lastname']}" />
<condition attribute="bd_birthdate" operator="on" value="@{triggerOutputs()?['body/bd_birthdate']}" />
</filter>
<condition attribute="bd_rrn" operator="eq" value="@{triggerOutputs()?['body/bd_rrn']}" />
</filter>
</filter>
</entity>
</fetch>

And I would add something to be sure that if the birthdate is null, the flow will not fail and list the records where there is no birthdate.

I have try to resolve this in this way:

<filter type="or">
<condition attribute="bd_birthdate" operator="null" />
<condition attribute="bd_birthdate" operator="on" value="@{triggerOutputs()?['body/bd_birthdate']}" />
</filter>

But my flow still fail on the second condition if my record have no birthdate...

I was thinking that maybe some kind of XML "if statment" to check if birthdate is not null before going into the second condition would maybe fix the problem, but I have no idea how to archive this... :/

Or if you have any suggestion on a better way to doing this, I would love to see you share your thoughts with me !

Thank you !

  • Suggested answer
    Naveen Ganeshe Profile Picture
    Naveen Ganeshe 3,393 User Group Leader on at
    RE: Nullable fetch XML (or If statment) problem !

    Hi DynaMoX,

    You can try this filter:

    <filter type="or">

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

       <filter type="and">

           <condition attribute="bd_birthdate" operator="on" value="@{triggerOutputs()?['body/bd_birthdate']}" />

           <condition attribute="bd_rrn" operator="eq" value="@{triggerOutputs()?['body/bd_rrn']}" />

       </filter>

    </filter>

  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,506 Super User 2024 Season 1 on at
    RE: Nullable fetch XML (or If statment) problem !

    I guess you can just fetch all the record where it having birthdate. It will solve the problem.

    And if you need all the records then first get all the records and add a condition stating if you have birthdate then using logic 1 else use logic 2....

    Thank you,

    Amit Katariya

  • Suggested answer
    Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Nullable fetch XML (or If statment) problem !

    Hi,

    Retrieve all records without adding birthdate condition in FETCHXML.

    Now, you can use NULL check condition in power automate to validate the Birthdate field.

    as described in below link:
    https://www.sharepointpro.com.au/blog/checking-if-string-is-empty-or-null-in-ms-flow-power-automate/

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans