3

I'm currently running into an issue with the following situation:

I have a right click event which executes a static method "inventTransferOrder". In that I have the following code:

select firstOnly invTransLine
where invTransLine.TransferId == invTrans.TransferId
   && invTransLine.LineNum == invTransLineNum;

args.record(invTransLine);

new MenuFunction(menuitemDisplayStr(InventTransferOrder), MenuItemType::Display).run(args);

In the form's (InventTransferOrders which lays behind the menu item InventTransferOrder) init method I'm executing the following code:

InventTransferLine      invTransLine;
QueryBuildDataSource    qbds;
QueryBuildRange         qbr;
;

invTransLine = element.args().record();

qbds = InventTransferLine_Q.dataSourceTable(tableNum(InventTransferLine));
qbr = qbds.addRange(fieldNum(InventTransferLine, LineNum));
qbr.value(strFmt('%1', invTransLine.LineNum));

This is doing exactly what it's supposed to do: it filters the grid using the data source 'InventTransferLine' to the one record with the matching LineNum.

Contrary to this, I need to show all records (the InventTransferLine gets prefiltered to only show the lines for the InventTransfer record that's selected) BUT the one record with the matching LineNum should be highlighted so that a user could start working with that line immediately.

Could anyone help me out with this?

I have used the following code, but it (visually) does not do anything:

InventTransferLine_DS.findRecord(invTransLine);
InventTransferLine_DS.mark(true);

I'd appreciate any help.

Thanks a lot and kind regards

Tekumi
  • 55
  • 1
  • 7

1 Answers1

2

It is a timing problem. Overwrite the executeQuery method of the InventTransferLine data source and put a breakpoint there. Also put a breakpoint in the init method where you wrote your modification. You will see that the breakpoint in init gets hit first and then the breakpoint in executeQuery. This means that executeQuery removes any selections and markings you have done previously.

If you put your modification in the executeQuery method after the super() call, your selection and marking should remain. Of course you do not want to execute this modification every time executeQuery gets called, so you will have to add some additional logic.

FH-Inway
  • 4,432
  • 1
  • 20
  • 37
  • Wow, that's a pretty simple and clear solution. I just moved the method and method call from form/init to datasource/executeQuery and it's working perfectly fine. TIL executeQuery deletes previous marking/selection. Thank you a lot! – Tekumi Apr 19 '16 at 12:02