I have to update the BOM Names of the selected records from a form, with the name inserted from a dialog, into 2 tables, namely the BOMTable and BOMVersion.
Basically:
I select some records from the Form, I click the update button, a dialog opens, the dialog has one empty field....what I write in the empty field needs to update the BOMTable and BOMVersion tables
The Form has a View as datasource.
I can read the View's records, and I can update the Tables with a given values, but I don't know how to pass/convert the View record from the Main method to the tables in the run() method:
public static void main(Args _args)
{
FormRun formRun = _args.caller() as FormRun;
//Read records
XYZ_RouteOprUpdView routeOprUpdView = _args.record() as XYZ_RouteOprUpdView;
//New Class instance
XYZ_RouteOprUpdUpdateBOMName bomNameUpdate = new XYZ_RouteOprUpdUpdateBOMName();
//Initialization
bomNameUpdate.parmMultiSelectionHelper(MultiSelectionHelper::createFromCaller(_args.caller()));
bomNameUpdate.parmRouteOprUpdView(routeOprUpdView);
bomNameUpdate.parmFormRun(FormRun);
// Prompt the dialog, if user clicks in OK it returns true
if (bomNameUpdate.prompt())
{
bomNameUpdate.run();
}
}
public void run()
{
BOMTable bomTable = multiSelectionHelper.getFirst();
BOMVersion bomVersion = multiSelectionHelper.getFirst() ;
while (bomTable && bomVersion)
{
ttsbegin;
bomTable.selectForUpdate(true);
bomTable.Name = bomTableName;
bomVersion.Name = bomVersionName;
bomTable.update();
bomVersion.update();
bomTable = multiSelectionHelper.getNext();
bomVersion = multiSelectionHelper.getNext();
ttscommit;
}
formRun.dataSource(tableStr(XYZ_RouteOprUpdView)).research(true);
}
My problem is that in the run() method I input a View record to the BOMTable and BOMVersion, that can't be implicitly converted into the table format.
BOMTable bomTable = multiSelectionHelper.getFirst();
BOMVersion bomVersion = multiSelectionHelper.getFirst() ;
bomTable ---> BOMTable type
multiSelectionHelper.getFirst() ------->XYZ_RouteOprUpdView type
But if I write:
BOMTable bomTable = multiSelectionHelper.getFirst() as BOMTable ;
it returns a null record.
How can I retrieve the 2 Table records from the View records?
Does your view have fields that you can use to find the BOMTable and BOMVersion records?
If yes, use those fields to find the corresponding BOMTable and BOMVersion records. Then update those records.