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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Creating a Report from Query

(0) ShareShare
ReportReport
Posted on by 495

Hello Guys, I have a question.... I need to created a report in AX 2012 R2...

I already know how to create the report and how to do everything in visual studio but each time I do it am only getting data form the first table(datasource) in the query...

These are the tables am using:   USTINVOICEJOUR, CUSTTRANS, CUSTSETTLEMENT

This is the query in SQL which works fine....

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-03-01 01:00:000' AND '2019-03-15 23:00:000'
 AND [CUSTSETTLEMENT].TRANSDATE <'2019-02-28 0:0:0'
 AND [CUSTINVOICEJOUR].INVOICEID LIKE 'ACP%'
 AND [CUSTINVOICEJOUR].INVOICEACCOUNT='110214M'

I would like for the where conditions to be dynamic where the user will then go and enter this info and the report prints according. IO know whats i get the query then dropping that in visual studio should not be a problem

Any help would be greatly appreciated if this can be achieved.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    You should not use direct SQL in AX because of various reasons you can easily find in the web. For simple report you can use AX query as described here community.dynamics.com/.../developing-ssrs-report-using-query-in-microsoft-dynamics-ax-2012

    But personally I prefer to build RDP based reports.

  • Blue Wang Profile Picture
    on at

    Hi Lionel,

     

    Have you considered using Procedure and editing code to complete logic?

    Procedure: It can set some variables for you to enter, specify the time range, and specify the InvoiceID.

    create procedure Createreportdynamically(

       //Define variables ,for example,

       @Begindate datetime,

       @Enddate datetime,

       @TransDate datetime,

       @Invoice nvchar(50),

       @InvoiceAcc nvchar(50))

    as

    BEGIN

    Insert your SQL here

    WHERE (Match with your custom variables)

    END

     

    exec Createreportdynamically '2018-03-01 01:00:000','2019-03-15 23:00:000','2019-02-28 0:0:0','ACP','110214M'

    Code: Backend development can access the database and call Procedure directly. Of course, parameters are what you are asked to enter when you create a report

    You can refer :https://www.cnblogs.com/armanda/p/6045963.html.

     

    Best Regards ,

    Blue Wang

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

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans