okneb1
1st July 2019, 14:52
Hello all,

We have a stand. LN session (modify) X for changing data (LN 10.5.)
X session has two fields, field A and field B. A is not part of the maintable (only form field), B is part of the maintable.

Now, when users inputs some value into field A and leaves it with tab (focus jumps on field B), field B gets recalculated, depending on the value in field A.

Recalculation for field B is done in the LN stand. program script in the before.checks and when.field.changes sections of the field A. But we cannot modify the stand. script.

Goal: Instead of user manually inputing value into A, session should have custom command, that calculates value in the field A - as a result field B also should get recalculated.

So, instead of:
A: User manually inputs value into field A, tab, value B gets recalculated
we should have:
B: User clicks on the form command, that fills the A, value B gets recalculated

We've added custom command for session X (session extension point - > new custom command). On command excecute the code fills some value in the field A (value gets displayed when field gets focus), but the field B doens't get recalculated when pressing TAB or setting focus on field B. Looks like the field A sections are not getting triggered. Custom form command is under Actions -> command name.

How can I trigger the when.field.changes or before.checks for field A with session extension point? Is this even possible?
I've already tried with check.all.input and display.fld, but it does nothing. Also I cannot use table extension, because field A is not part of the table, it's only defined as a formfield.

JaapJD
1st July 2019, 15:26
I think it will work if you link the custom form command to the field A. So, the Command Type of your form command must be Field. Then you can select field A in the Field property. In the implementation of the Command Execute hook, you must do something like:

A = <something>
display("A")

After pressing the Tab, B will be calculated and shown. And there is another advantage, the button is just behind field A.

okneb1
1st July 2019, 15:29
JaapJD, thank you for the suggestion.

The field A already has stand. button behind it (for calculating default values). :)
If I try adding the command as type field on A, it's doesn't get displayed. Probably there is a limit for only one button per field.

One option here would be to override this stand. command in before.command (extension) with customized code followed by choice.again().
Or maybe adding the additional dialog on before stand. command, asking user if he wants to run stand. command or custom one (again with the choice.again or no change).

JaapJD
1st July 2019, 16:05
Then you have the possibility to extend the standard form command that is linked to field A. If you need still the default behavior you can ask the user at runtime if he wants the default value or another calculated value. Then the code of the Before Command hook could be something like:

if ask.enum("txdefault", tcyesno.no) = tcyesno.no then
|* new question to be created in tx package
A = <something>
display("A")
choice.again()
endif

So, if the user wants the custom calculation of A, that is done here and by coding the choice.again(), the default calculation is skipped. Otherwise the default calculation is executed. To complete it, you can modify the text on the field button by selecting Overwrite Description.

okneb1
1st July 2019, 16:26
Thank you. It works!