I’m passing records from an existing form to a new form.
Existing form: ProjSalesItemReq
New form: DIReturnItems
The new form is in the pattern Dialog-FastTabs and contains a grid an Ok and Cancel buttons.
The problem is that the records that I’m selecting from the existing form, does not appear on my new form, until I hit the Cancel button. When the new form (DIReturnItems) opens, the grid is empty, and when I hit the cancel button, the records appear, and the form is not Cancelled. The Cancel button is the normal Cancel command button.
I’ve extended the ProjSalesItemReq form to include a button that calls the DIReturnItems form.
Here is the code behind the clicked event (I build a container with SalesLine RecIds):
[ExtensionOf(formControlStr(ProjSalesItemReq,DIReturnItems))]
final class ProjSalesItemReqDI_Extension
{
//Get the selected records
public void clicked()
{
int recordsCount;
SalesLine salesLine;//SalesTable salesTable;
container con;
Args args;
str multiSelectString;
FormControl formButtonControl = any2Object(this) as FormControl;
FormDataSource salesLine_ds = formButtonControl.formRun().dataSource(tableStr(SalesLine));
args = new Args();
recordsCount = salesLine_ds.recordsMarked().lastIndex();
salesLine= salesLine_ds.getFirst(1);
while(salesLine)
{
con = conIns(con,1, salesLine.RecId);
multiSelectString = con2Str(con,',');
salesLine= salesLine_ds.getNext();
}
args.parm(multiSelectString);
new MenuFunction(menuitemActionStr(DIReturnItems), MenuItemType::Action).run(args);
next clicked();
}
}
The DIReturnItems form’s datasource is a temp table (of type InMemory), which receives the SalesLine recIds, and populates a temp table.
On the init of the DIReturnItems form, I receive the container and populate the temp table, herewith the code:
public void init()
{
container con;
DIReturnItemsListTemp returnItemListTmp;
SalesLine salesLine;
int iCnt;
super();
multipleRecords = element.args().parm();
con = str2con(multipleRecords,',');
for(iCnt = 1;iCnt<= conLen(con) ;iCnt++)
{
salesLine = salesLine::findRecId(conPeek(con,iCnt));
returnItemListTmp.SalesId = salesLine.SalesId;
returnItemListTmp.ItemName = salesLine.itemName();
returnItemListTmp.ItemId = salesLine.ItemId;
returnItemListTmp.UpdateQty = salesLine.SalesQty;
returnItemListTmp.OrigQty = salesLine.SalesQty;
returnItemListTmp.SalesLineRefRecId = salesLine.RecId;
returnItemListTmp.SalesTableRefRecId = SalesTable::find(salesLine.SalesId).RecId;
returnItemListTmp.ProjId = salesLine.ProjId;
returnItemListTmp.insert();
}
DIReturnItemsListTemp.setTmpData(returnItemListTmp);
}
The data is populated, but only when clicking the Cancel button.
My question is, why is the data only refreshed, or shown on the Cancel click? What is happening behind the Cancel button that is refreshing the form to show the data?