web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 168 Super User 2026 Season 1

#2
NeerajPawar Profile Picture

NeerajPawar 65

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 51 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans