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

convert fetch xml to sql query

(0) ShareShare
ReportReport
Posted on by 5

Hello All,

This is humble request, if possible, then please reply early for below concern.

Please help me to convert fetch xml into sql query

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="logmechanism">
<attribute name="name" />
<attribute name="createdon" />
<attribute name="src_bo" />
<attribute name="toendpointid" />
<attribute name="messagestatus" />
<attribute name="messageid" />
<attribute name="errordetails" />
<attribute name="src_app" />
<attribute name="messagetype" />
<attribute name="logmechanismid" />
<attribute name="workorder" />
<order attribute="createdon" descending="true" />
<filter type="and">
<condition attribute="messagetype" operator="eq" value="0" />
<filter type="or">
<condition attribute="src_bo" operator="eq" value="service" />
<condition attribute="src_bo" operator="eq" value="feedback_new" />
</filter>
<condition attribute="createdon" operator="on-or-before" value="2023-05-24" />
</filter>
<link-entity name="workorder" from="workorderid" to="workorder" link-type="inner" alias="al">
<filter type="and">
<condition attribute="systemstatus" operator="not-in">
<value>2</value>
<value>1</value>
</condition>
</filter>
</link-entity>
</entity>
</fetch>

I have the same question (0)
  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi D365 Technical consultant 

    Use Fetch XML Builder in XRM Toolbox.

  • Suggested answer
    PerezAguiar Profile Picture
    Microsoft Employee on at

    Hey!

    I think it would be something like this:

    SELECT L.name, L.createdon, L.src_bo, L.toendpointid, L.messagestatus, L.messageid, L.errordetails, L.src_app, L.messagetype, L.logmechanismid, L.workorder
    FROM LogMechanism L
    INNER JOIN WorkOrder AL ON AL.workorderid = L.workorder AND (AL.systemstatus NOT IN (1,2))
    WHERE messagettype = 0
    AND (src_bo = 'service' OR src_bo = 'feedback_new')
    AND createdon <= '2023-05-24'
    ORDER BY createdon

    Regards,

  • Suggested answer
    ankit_singhal Profile Picture
    560 on at

    Your query will look like :

    Select L.name, L.createdon, L.src_bo, L.toendpointid, L.messagestatus, L.messageid, L.errordetails, L. src_app, L.messagetype, L.logmechanismid, L.workorder, W.systemstatus from  logmechanism L

    inner join workorder W on L.workorderid = W.workorder

    Where L.messagettype = 0

    AND (L.src_bo = "service" OR L.src_bo = 'feedback_new')

    AND L.createdon <= '2023-05-24' and W.systemstatus NOT IN (2,1)

    ORDER BY L.createdon

    Mark my answer As Verified if it is helpful.

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 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

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

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans