Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Query Object convert SQL into BC Query

Posted on by 7
SELECT [No], [Document Type]
FROM [Sales Header]
WHERE [Document Type] = 'Sales Order'
    OR ([Document Type] = 'Sales Quote' AND [Order Received] = 1);

I have extended a field in Sales Header /Order Received/ 

My requirement is to find all records which has  Document Type as 'Order' or Document Type as 'Quote' but when the document type is Quote it should also check if Order Received is TRUE

  can we write a query for these type of requirement?
Categories:
  • Query Object convert SQL into BC Query
    I have implemented but it is only showing records which has Order Received as True

    What I actually needed is ALL Sales Orders and from Sales Quote records only which as, "Order Received"  field marked as True



  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,110 Super User 2024 Season 2 on at
    Query Object convert SQL into BC Query
    Hi, just add some information. If your Query is used in code, you can also use SetFilter or SetRange to add filtering. This is similar to record (table).
     
    Hope this helps.
    Thanks.
    ZHU
  • Suggested answer
    Dustin Wolf Profile Picture
    Dustin Wolf 30 on at
    Query Object convert SQL into BC Query


    You would probably want something like this.  The DataItemTableFilter will help with the WHERE
  • gdrenteria Profile Picture
    gdrenteria 11,988 Most Valuable Professional on at
    Query Object convert SQL into BC Query
    Hi
    Surely you could apply a couple of dataitems, each with its premises, and join them. I hope this helps you a little.
    Best regards
    Gerardo

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!

Community AMA December 12th

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

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,963 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans