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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Query Object convert SQL into BC Query

(1) ShareShare
ReportReport
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?
I have the same question (0)
  • Gerardo Rentería García Profile Picture
    25,078 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
  • Suggested answer
    Dustin Wolf Profile Picture
    30 on at
    Query Object convert SQL into BC Query


    You would probably want something like this.  The DataItemTableFilter will help with the WHERE
  • Suggested answer
    YUN ZHU Profile Picture
    95,305 Super User 2025 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
  • Community member Profile Picture
    7 on at
    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



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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans