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