Set fields Read Only for some groups on Update, but not Insert

Hi

I have two groups with users assigned using the SC Security module (SC V9.8.011)

I would like one group to be able to insert a form and have access to all fields, but on update only access certain fields.

The other group should be able to insert and update all fields.

I’m trying something like this:

if ([var_group] == 0) AND (!sc_btn_insert) // Set as read-only)
{
sc_field_readonly({faultCat}, ‘on’);
sc_field_readonly({faultActivity}, ‘on’);
sc_field_readonly({ReportedBy}, ‘on’);
sc_field_readonly({Photo}, ‘on’);
}

If I omit the second condition, the form works as expected (key fields are set as read only), however I cannot seem to enable fields where the activity is an insert rather than an update.

Any clues?
Regards
Craig

Hi,
When you are going to insert, normally your key fields will be 0 or ‘’, while if you are going to edit, it will have a value.
That way you can see if you are in insert or update mode.

Hi, you have to use the macro sc_btn_new, to detect in the form is in insert new record or update record mode, warning, that macro is valid only in OnLoad event.

1 Like

Thank you to both of you.

I used Vincenzo’s solution (sc_btn_new) along with a custom add on to the security system

  • sec_login assigns a variable to the logged in user, indicating their access rights
  • The form disables all fields using sc_field_readonly for each field
  • a conditional then enables fields depending on the users assigned group.

When sc_btn_new is true, a conditional enables all fields.

Thanks for your help,

Regards
Craig

1 Like