Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Selecting a range to print Sales Account and the Details

Posted on by Microsoft Employee

I' ve created a set of report classes. Currently I m only able to print on a selected sales account and it details. what I wanted is to print a selected range of sales account. from example the sales accountfrom is 520 and sales accountto is 900. Then the report will print the selected salesaccount into the report.  Where can I add the range for my code? 

// Data provider

[ //SRSReporueryAttribute(queryStr()),
SRSReportParameterAttribute(classStr(TestingSalesContract))
]


class TestingSalesDataProvider extends SRSReportDataProviderBase

{
    Testing_SalesLine      salesLine;
    Testing_SalesHeader1    salesHeader;
    Testing_SalesLineTmp    salesLineTmp;
    TestingSalesContract    contract;
    RecordInsertList        recordInsertListTmpTable;


}

[SRSReportDataSetAttribute(tablestr('Testing_salesLineTmp'))]
public Testing_salesLineTmp getSalesLine()
{
    ;
    return salesLineTmp;
}

[SysEntryPointAttribute]
public void processReport()
{
     Testing_SalesAccount       salesAccountFrom;
    Testing_SalesAccount        salesAccountTo;
    ;
    contract = this.parmDataContract() as TestingSalesContract;
    salesAccountFrom = contract.parmSalesAccountFrom();
    salesAccountTo  = contract.parmSalesAccountTo();
    
    



    while select * from salesLine //select all dat  from sales line
    
       
    where salesLine.SalesAccount == salesAccountFrom // if  input sales acccount was equal then showdata
    
    {// print to tmp table
        salesLineTmp.clear();
        salesLineTmp.SalesAccount = salesLine.SalesAccount;
        salesLineTmp.CustomerID = salesLine.CustomerID;
        salesLineTmp.CustomerName = salesLine.CustomerName;
        salesLineTmp.ItemID =  salesLine.ItemID;
        salesLineTmp.ItemName = salesLine.ItemName;
        salesLineTmp.ItemPrice = salesLine.ItemPrice;
        salesLineTmp.ItemQuantity = salesLine.ItemQuantity;
        salesLineTmp.ItemTotal = salesLine.ItemTotal;
        salesLineTmp.insert();
    }
}




//UI builder

class TestingSalesUIBUilder extends SysOperationAutomaticUIBuilder
{
    TestingSalesContract contract;

    DialogField     dialogSalesAccountFrom;
    DialogField     dialogSalesAccountTo;

}

public void build()
{
    contract = this.dataContractObject();

    dialogSalesAccountFrom = this.addDialogField(methodStr(TestingSalesContract,parmSalesAccountFrom),contract);
    dialogSalesAccountTo = this.addDialogField(methodStr(TestingSalesContract,parmSalesAccountTo),contract);



}

//contract 

[DataContractAttribute,
SysOperationContractProcessingAttribute(classstr(TestingSalesUIBUilder))
]
class TestingSalesContract
{
    Testing_SalesAccount     salesAccountFrom;
    Testing_SalesAccount    salesAccountTo;


}

[DataMemberAttribute('salesAccountFrom') ]
public Testing_SalesAccount parmSalesAccountFrom(str _salesAccountFrom = salesAccountFrom)
{
    salesAccountFrom = _salesAccountFrom;
    return salesAccountFrom;

}

[DataMemberAttribute('salesAccountTo') ]
public Testing_SalesAccount parmSalesAccountTo(str _salesAccountTo = salesAccountTo)
{
    salesAccountTo = _salesAccountTo;
    return salesAccountTo;

}

// controller

class TestingSalesController extends SrsReportRunController
{


}

public static void main(Args _args)
{
    TestingSalesController controller;

    ;

    controller = new TestingSalesController();


    controller.parmArgs(_args);
    controller.parmReportName(ssrsReportStr(TestingSales, PrecisionDesign1  ));
    controller.parmDialogCaption('SalesLine');

    controller.startOperation();

}


*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Selecting a range to print Sales Account and the Details

    never mind I found the problem it was the dataset from visual studio. Thank for helping me Istvan.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Selecting a range to print Sales Account and the Details

    Yeah I got what I wan with this query. but I could get the salesAccountTo.

    I tried change the "<=" only sales accountfrom work. salesAcoountTo print nthing

  • Suggested answer
    István Orosz Profile Picture
    István Orosz 2,137 on at
    RE: Selecting a range to print Sales Account and the Details

    This line should be modified:

     where salesLine.SalesAccount == salesAccountFrom // if  input sales acccount was equal then showdata

    in public void processReport()

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Selecting a range to print Sales Account and the Details

    Where do i add the query? Do you have any example of it?

  • Verified answer
    István Orosz Profile Picture
    István Orosz 2,137 on at
    RE: Selecting a range to print Sales Account and the Details

    Hi,

    You should modify the processReport() main query to something like this:

    salesLine.SalesAccount >= salesAccountFrom && salesLine.SalesAccount <= salesAccountTo

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!

Community AMA December 12th

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans