Saltar al contenido principal

UF with Macro to change value of Read Only field

Respondida

Comentarios

6 comentarios

  • Comentario oficial
    Yaremi Miranda Lopez

    Hello Ere,

    If you're using the Read Only functionality then you can't modify the value with a Macro. What you can do in this case is the following: Add a B1 Validation system on Form Load that executes a Macro. This macro has the command Disable($[$item.col.0]);

    In your macro, you can add the Enable($[$item.col.0]); command before your set and the Disable again after.

    You can also "play" with the user's definitions in the validations so you don't have to add this in your macros.

     

  • David Stegnitz

    Hi Yaremi Miranda Lopez,

    I've followed your approach and it works fine. However, if you edit any other field in the same form, or navigate from one to the next record without closing the form, the disabled field automatically gets enabled again. Would you have an advise how to avoid this?

    Thanks, David

  • Geoff Booth

    Try switching the validation to after data load instead of form load (hopefully the resizing doesn't reload the data).

    If not, then I think you need to add a validation on the field itself to block any changes.

     

    Good luck

  • David Stegnitz

    Hi Geoff Booth 

    Thank you for the reply. Data Load trigger does not disable the field. A validation on the field won't work, since similar to the original question in this post, I have a different macro which temporarily enables the field to update its value, and then disables it again. Basically the idea is to have a field, which can only be changed by a B1UP macro, but not by a user manually. 

    Thanks, David

  • Geoff Booth

    Does the field need to be visible?

    If not then possibly "Hide" the field on Form Load and then add the show & hide to your set macro?

  • David Stegnitz

    Hi Geoff Booth

    I have the issue with a field value which needs to be displayed and with a hidden button. The issue with the Button is that it can be pressed with a hot-key combination (Alt+S), so user could theoretically find a 'work-around' to bypass the validation. 

    So basically only the Macro should be able to change the field and click the button. Not the user manually. I also cannot use the 'disable item' option, as then even the Macro won't be able to enable the field. It seems I can only use a Validation, but here I got the described problem that the Validation doesn't trigger if the user navigates to the next record, or if the user changes any field on the already loaded form. 

    Any hints are appreciated. 

    Thanks, David

Iniciar sesión para dejar un comentario.