Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Multiple records printing

(0) ShareShare
ReportReport
Posted on by 45

Hi all,

I'm quite new to the ax. The situation is like this.

I would like to print multiple official receipt . the current way is , they can only print line by line. but i would like to include all the records displayed and print it. The form is directly link to the report and the datasource is by query which i dont really know how to use it.

i managed to get the selected records in the clicked method in the form, but when it comes to the report, it loops the same records although the count of the loops is correct. So my problem is, how to make the query run into the next record?

Attach is the code.  thanks !

Form:

void clicked()
{
LedgerJournalTrans ledgerJournalTranstbl;
;

ledgerJournalTrans = ledgerJournalTrans_ds.getFirst(true);

while (ledgerJournalTrans)
{


info(strfmt(" %1 | %2 | %3", ledgerJournalTrans.AccountNum,
ledgerJournalTrans.MarkedInvoice,
ledgerJournalTrans.JournalNum));
super();
ledgerJournalTrans = ledgerJournalTrans_ds.getNext();

}

}

Report:

public void init()
{
element.initFromArgs(element.args());
info(ledgerJournalTrans.MarkedInvoice);
element.initializeQuery();
super();
monthMap = new Map(Types::String, Types::Real);
}

void initFromArgs(Args args)
{

if (args && args.dataset())
{
switch(args.dataset())
{
case tablenum(LedgerJournalTrans) :
ledgerJournalTrans = args.record();
break;

case tablenum(LedgerJournalTable) :
ledgerJournalTable = args.record();
break;

}

}
}

public void initializeQuery()
{
QueryBuildRange rangeJournalNum;
QueryBuildRange rangeVoucher;
QueryBuildRange rangeAccountType;
;

query = element.query();


if (ledgerJournalTrans)
{
rangeJournalNum = query.dataSourceTable(tablenum(LedgerJournalTrans)).findRange(fieldnum(LedgerJournalTrans,JournalNum));
rangeVoucher = query.dataSourceTable(tablenum(LedgerJournalTrans)).findRange(fieldnum(LedgerJournalTrans,Voucher));
rangeAccountType = query.dataSourceTable(tablenum(LedgerJournalTrans)).findRange(fieldnum(LedgerJournalTrans,AccountType));

if (!rangeJournalNum)
rangeJournalNum = query.dataSourceTable(tablenum(LedgerJournalTrans)).addRange(fieldnum(LedgerJournalTrans,JournalNum));

if (!rangeVoucher)
rangeVoucher = query.dataSourceTable(tablenum(LedgerJournalTrans)).addRange(fieldnum(LedgerJournalTrans,Voucher));

if (!rangeAccountType)
rangeAccountType = query.dataSourceTable(tablenum(LedgerJournalTrans)).addRange(fieldnum(LedgerJournalTrans,AccountType));

rangeJournalNum.value(QueryValue(LedgerJournalTrans.JournalNum));
rangeVoucher.value(QueryValue(LedgerJournalTrans.Voucher));
rangeAccountType.value(QueryValue(LedgerJournalACType::Cust));

}

}

boolean fetch()
{
;

queryRun = new QueryRun(this);

while (queryRun.next())
{
ledgerJournalTrans = queryRun.get(tablenum(LedgerJournalTrans));

element.buildSettleAmountList();

element.send(ledgerJournalTrans);

/*
mapEnumerator = new MapEnumerator(monthMap);

while (mapEnumerator.moveNext())
{
info(strfmt("%1 -- %2", mapEnumerator.currentKey(), mapEnumerator.currentValue()));
}
*/
}

return true;
}

*This post is locked for comments

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,961 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,801 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans