How to transfer multiple records between two forms?

I want to transfer multiple entries between two forms. The user opens Form-A, selects a few entries, and then clicks the button that opens Form-B. There are two (or more) StringEditcontrols in Form-B , and they should display the values ​​from the selected records.

I know how to transfer only one record, for this I use the following code in the Form-B method:

if (element.args().parmEnumType() == enumNum(NoYes) 
 && element.args().parmEnum() == NoYes::Yes)
{
    myTable = element.args().record();
    stringEdit.text(myTable.Field);
}

How can I change my code so that I can set the text of another element StringEditto the field value of the next record that the user selected?

+4
source share
2 answers

args , -A, (, SalesTable);

int         recordsCount;
SalesTable  salesTable;
container   con;
Args        args = newArgs();

// gets the total records selected
recordsCount = salesTable_ds.recordsMarked().lastIndex();
salesTable = salesTable_ds.getFirst(1);
while(salesTable)
{
    // storing recid of selected record in container
    con = conIns(con,1, salesTable.RecId);
    salesTable = SampleTable_ds.getNext(); // moves to next record
}   
// passing container converted to string 
args.parm(con2Str(con,','));

-B init(), ,

. init() ,

public void init()
{
    container   con;
    int         i;
    super();       
    // string to container
    con = str2con(element.args().parm(),'','');    
    // for sorting
    for(i = 1;i<= conLen(con) ;i++)
    {
        salesTable_ds.query().dataSourceTable(Tablenum(SalesTable)).addRange(fieldNum(SalesTable,RecId)).value(SysQuery::value(conPeek(con,i)));
    }
} 

, .

Ax-Forum

+5

Form-A Form-B.

for getFirst getNext :

SalesLine sl;
FormDataSourcs ds = _salesLine.dataSource();
for (sl = ds.getFirst(true) ? ds.getFirst(true) : ds.cursor(); sl; sl = ds.getNext())
{       
    //Do your thing, add a query range
}

MultiSelectionHelper , :

public void init()
{
    MultiSelectionHelper ms;
    super();       
    if (element.args() && element.args().caller() && element.args().record())
    {
        this.query().dataSourceTable(tableNum(SalesLine)).clearDynalinks();
        ms = MultiSelectionHelper::createFromCaller(element.args().caller());        
        ms.createQueryRanges(this.query().dataSourceTable(tablenum(SalesLine)), fieldstr(SalesLine, InventTransId));
    }
}
+2

All Articles