1

I have a question regarding on how to retrieve the records that I have selected in a form, to a report.

Currently, I am able to select multiple records, but when it comes to the report, it keep on processing the same value. However the number of the records that it processed is correct, only the value is repeating.

I am not sure on how to fix this, therefore your help is kindly appreciated.

Below is the part that i get the record:

if (element.args() && element.args().dataset())
{
    switch(args.dataset())
    {
        case tablenum(LedgerJournalTrans) :
            ledgerJournalTrans = element.args().record();
            info(ledgerJournalTrans.Voucher);
            break;    
        case tablenum(LedgerJournalTable) :
            ledgerJournalTable = args.record();
            break;
    }    
}
Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
anne.M
  • 13
  • 3
  • Possible duplicate of [X++ passing current selected records in a form for your report](https://stackoverflow.com/questions/10014177/x-passing-current-selected-records-in-a-form-for-your-report) – FH-Inway May 03 '18 at 05:43
  • yes it is,but i found another solution to solve my question. Thanks FH ! – anne.M May 07 '18 at 05:43
  • Good work. If you like, you can post your solution as answer to your or the duplicate question so others can find it. – FH-Inway May 07 '18 at 08:43

1 Answers1

0

The element.args().record() only points to the last selected record. Its datasource comes to rescue. The usual approach to process multi-selected records applies:

Common record;
FormDataSource fds;
fds = element.args().record().dataSource();
for (record = fds.getFirst(1) ?  fds.getFirst(1) : fds.cursor(); record; record = fds.getNext())
{
     // Do the printing using record
}

You often see this approach used in main methods of functions capable of processing multi-selected records.

The FormLetter.getFormRecord uses this pattern as well.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • Thanks Jan for the help. I tried to use this method also however the record did not move to the next record either. maybe i placed it wrongly. I do found another solution for the question though. – anne.M May 07 '18 at 05:42