Skip to main content

Notifications

Announcements

No record found.

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,698 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 12,183 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!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans