Set form to READONLY by user level

This is a grid / form (single record) application.

What I gonna have is:-
For Management Level,
Allow to Add / Update / Delete record for the application.

For Normal User Level,
Only allow to VIEW, no Add / Update / Delete features.

Btw, I have a global variable to keep track the User Level (1 for Management / 0 for Normal User)

Any idea how to do this?

Regards,
CK Kong

Re: Set form to READONLY by user level

Have a look at:

sc_field_readonly({my_field});
sc_btn_display(“button”,“on/off”)

Regards,
Scott.

Re: Set form to READONLY by user level

I knew about this function.

sc_field_readonly({my_field});

But I have about 20 forms & some of them with 40 fields.

Is there any other easy way? Like create another link, then user level go to link2

eg. sc_link(column, application, parameters, hint, target)

But how to tell the program to visit standard link when access as Management and readonly link when login as user?

Regard,
CK

Re: Set form to READONLY by user level

That is how I do it … I create a separate form for view. I then decide to show the add/edit/delete buttons if they are allowed.

I just create an edit form and get it like I want, then I will duplicate it to an add form and then a view form (view: all fields RO). It is a bit more work since you have multiple forms, but I have more control over my forms than trying to use the default logic in SC5 when in insert/update mode.

I always present a VIEW screen to all users. IMO, there is no need to EDIT unless need to, even if you are Admin.

Your option will work as well, using a condition for sc_link().

onRecord event:

if(level = admin_level) {
sc_link(column,edit_form, …);
} else {
sc_link(column,view_form, …);
}

Re: Set form to READONLY by user level

Dear Scott,

But I’m using grid / form (Single row). There is a pencil icon there. Can I just click on the icon and the check will start at that moment?

Which event I should modify?

Because of the Grid / Form link, there is a Link Application on the link module?

According to my limited knowledge, sc_link() must supply with a field, but what is the field for the pencil icon?

Regards,
CK

Re: Set form to READONLY by user level

Sorry for the confusion …

The toolbar buttons will control what is available on each record for editing … pencil/trash, etc.
You can set the sc_btn_display(“button”,“on/off”) based on your security in the onLoad event.

When the user loads the form, admin will see icons on each record. Users will just see data.

If you need to provide a link to another app for admins only, then create a ‘new field’ of type ‘html image’ and provide and icon and use ‘edit link’ button under the image selector. Yuo can then use sc_field_display() in onLoad to decide of the field will be available.

Regards,
Scott.