Macro 'sc_field_display' with variables

Hi everyone!

They’ve asked this question several times before, but it’s been 6 years since the last time and I was wondering if anything has changed in the meantime.

The ‘sc_field_readonly’ macro also accepts variables as an argument, for example:
$strFieldName = “mYField”;
sc_field_readonly($strFieldName, on);

Instead, the ‘sc_field_display’ macro would appear to only accept names in curly braces.
Since I get the field names from the database to automate which fields are visible depending on the user’s group, I was wondering if something has improved in the meantime or if there is a system to get around this strange omission.

I already know that I could use the ‘switch’ construct for each variable and thus use the original name with the curly braces, but I would thus lose useful automation and with any modification of the form (for example with new fields)
I should also change to the source code.

It all stems from a simple request: to make the fields of a form so that they are read-only and/or visible depending on the group a user belongs to. Read only which, luckily, as mentioned before I was able to automate because the ‘sc_field_readonly’ macro can use variables.

I contacted tech support and they explained that instead of putting the ‘sc_field_display’ macro on the ‘OnLoad’ event I should put it on the ‘OnLoadRecord’ event. I’ve tried it but can’t get it to work.
I had, perhaps wrongly, figured out that if I put ‘sc_field_display($strFieldName, …)’ on the ‘OnLoadRecord’ event it could accept variables.
I don’t know if I misunderstood or am doing something wrong.

Thanks

In case anyone needs it, for now I’ve found a workaround, I’ve copied the source code generated by the ‘sc_field_display’ macro and put it directly into the OnLoad event with the only difference being that I used a php variable instead of the field name which was in the curly braces.
Naturally it is important that with each update of ScriptCase it is checked that the output of the ‘sc_field_display’ macro has not changed in the meantime.

On the forum I had read that others recommend using styles, but in this case it would be simple to make the fields visible by altering the style of the hidden fields from the client browser.