Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

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;
}

Categories:

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,663 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 224,750 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans