I’ve tried a client script on the Sales Invoice doctype to automatically set the default print format based on condition. It used to work perfectly before, but recently it does not always set the correct print format when I open or create new Sales Invoices. Sometimes the print format updates correctly, but other times it doesn’t.
How to consistently update default custom print format based on condition every time the form loads ?
Yes. I’ve already tried using refresh, onload and onload_post_render, but the issue still persists.
The problem seems to be that after reloading, the print format of the first Sales Invoice I open is applied to all subsequent invoices I open afterwards unless I reload again — even if they have a different naming series.
I think you may need to troubleshoot when/why it works vs when/why it doesn’t work. For example; does it matter how the user has Sales Invoice list filters set, does it happen for all users, etc.