I have a script that checks and unchecks rows in a child table according to data in some reference fields.
After the form saves the checks disappear from the table! Not what I want.
I have a method rePaintChildTable() that is called when there are any changes to one of the reference fields.
If I change data, manually, in any of those fields rePaintChildTable() restores the check marks.
If I change the data, programmatically, in one of those fields in the “after_save” event handler and then call rePaintChildTable() my results in console.log() are exactly the same as I see when making a manual edit, but nothing happens. The check marks are not rendered to the user view
const after_save = () => {
const event = "after_save";
console.log(`########################## -->| ${event} |<-- ############################`);
this.frm.doc.serial_numbers += ",";
this.frm.refresh_field('serial_numbers');
this.frm.events.repaintcntr(event);
return;
}
[ this.frm.events.repaintcntr(event) calls rePaintChildTable() ]
Also, after the line this.frm.refresh_field('serial_numbers'); I would expect to see a comma appear in the serial_numbers text_area, but it remains unchanged.
Finally, as soon as I interact with the form, manually, in any way, my scripts seem to regain control over the visible form.
It seems as if, between “after_save” and before first user action, JavaScript operates on a shadow that is not rendered to the user.
Weirder still … this ONLY happens the first time I save, after that it all works as expected.
Is this a known issue?
Any hints on how to deal with this?