Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Multiple records printing

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

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,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