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 :
Microsoft Dynamics AX (Archived)

Converting SQL query to X++

(0) ShareShare
ReportReport
Posted on by 495

Hello,

I don't know X++ but I know a little SQL... I have this query that I need to write in X++ can someone please help.

Query:

SELECT

   INVOICEID

  ,INVOICEACCOUNT

  ,INVOICINGNAME

  ,CUSTSETTLEMENT.DUEDATE

  ,CUSTSETTLEMENT.CREATEDDATETIME

  ,CUSTSETTLEMENT.TRANSDATE

  ,CustSettlement.SETTLEAMOUNTREPORTING  

  ,INVOICEAMOUNT

  ,PAYMENT      

  ,INVOICEAMOUNTMST

 FROM CUSTINVOICEJOUR join CUSTTRANS ON CUSTTRANS.INVOICE=CUSTINVOICEJOUR.INVOICEID AND  CUSTTRANS.AccountNum = CUSTINVOICEJOUR.InvoiceAccount

and CUSTTRANS.TransDate = CUSTINVOICEJOUR.InvoiceDate

and CUSTTRANS.Voucher = CUSTINVOICEJOUR.LedgerVoucher

join CUSTSETTLEMENT

on CUSTSETTLEMENT.TransCompany = CUSTTRANS.dataAreaId

and CUSTSETTLEMENT.TransRecId = CUSTTRANS.RecId

and CUSTSETTLEMENT.AccountNum = CUSTTRANS.AccountNum

WHERE CUSTSETTLEMENT.DUEDATE = CUSTINVOICEJOUR.DUEDATE

AND CUSTSETTLEMENT.DUEDATE between'2018-09-01' AND '2019-08-31'

AND CUSTSETTLEMENT.TRANSDATE <'2019-08-31 0:0:0'

AND CUSTINVOICEJOUR.INVOICEID LIKE 'ACP%'

AND CUSTINVOICEJOUR.INVOICEACCOUNT='XXXXXX'

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Imran Ali Memon Profile Picture
    61 on at

    while select * from FROM CUSTINVOICEJOUR

    join CUSTTRANS where CUSTTRANS.INVOICE== CUSTINVOICEJOUR.INVOICEID

    && CUSTTRANS.AccountNum == CUSTINVOICEJOUR.InvoiceAccount

    && CUSTTRANS.TransDate == CUSTINVOICEJOUR.InvoiceDate

    && CUSTTRANS.Voucher = CUSTINVOICEJOUR.LedgerVoucher

    join CUSTSETTLEMENT

    where CUSTSETTLEMENT.TransCompany == CUSTTRANS.dataAreaId

    && CUSTSETTLEMENT.TransRecId == CUSTTRANS.RecId

    && CUSTSETTLEMENT.AccountNum == CUSTTRANS.AccountNum

    && CUSTSETTLEMENT.DUEDATE == CUSTINVOICEJOUR.DUEDATE

    && CUSTSETTLEMENT.DUEDATE >='20180901'

    && CUSTSETTLEMENT.DUEDATE <='20190831'

    && CUSTSETTLEMENT.TRANSDATE <'20190831'

    && CUSTINVOICEJOUR.INVOICEID LIKE 'ACP*'

    && CUSTINVOICEJOUR.INVOICEACCOUNT=='XXXXXX'

  • Lionel07 Profile Picture
    495 on at

    Hey Imran, thanks much for your help.. the query worked perfectly. I have one problem though,

    When designed my form I need to change the field labels. like due date should say: "From Date" and To date. how can I do that? see image with the issue.

    change-labels-on-form.png

  • Imran Ali Memon Profile Picture
    61 on at

    change the label of fields on forms

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans