Hide/Show and Custom function in Creator

Hide/Show and Custom function in Creator

Hello,

I tried to do a function where I want to hide/show some fields of the form. Like the following code

  1. void dossier.showFinanceursFieldsAccordingToPlanFinancement (Dossier dossier) {
  2.   hide dossier.Orient_par_Entreprise;
  3. }
However creator triggers here an error telling me " 'hide' can be used only in on load actions "
Do anybody knows a workaround to that situation? Like creating function that only works on load actions for example?

The goal is to avoid code repetition, as currently, I need to copy and paste the same code in both on add > on load + on edit > on load event, which is not very DRY and sustainable.

Thank you!