A code to make a for editable when i login with my user id and non editable

Dear All,

I need a code that will make my form editable when i login with my user id and non editable when others login. I also need a code that will also tell me if a code(like location code) has been existing when ever i try inserting the same code.

Regards

Gbenga

Hi Gbenga

With Hard Coding


  1. Place the belo code at OnOpenForm()

IF UPPERCASE(USERID) <> ‘Jerome Marshal’ THEN
CurrForm.EDITABLE(FALSE);

Without hard coding


1.Create a field in user setup table(91) with data type as Boolean for example Allow to Edit

2.create user setup table(91) as a variable in the form for example userSetup

3.place the below code at OnOpenForm()

if usersetup.get(USERID) then

if not usersetup.“Allow to Edit” then

CurrForm.EDITABLE(FALSE);

Thanks

Jerome marshal.j

My way is this
Create a role
Assign users to the role
In your form, check whether current user is member of the role (table 2000000003)

Doing it this way you can manage [hardcoded] access with out changing the object.
The role does not have to contain any permissions.

Dear Anfinnur

the table 2000000003 only holds the records of the users ,who can able to login to Navision

using Database login access. So my question is how will you control the windows login users if you the table 2000000003 ?

Thanks

Jerome Marshal.J

Hello Gbenga ,

pls. follow the Anfinnur’s suggestion. - It is 100% right & 200% right away.

Create proper role and assign those role to the desired USER(Database user or Window login user).

  • not quite right. The name of that table is “Member of” and contains the combinations of users and roles. Which means “which role does a user belong to” and “which users are assigned to this role”.

Hi Guys,

Thanks alot for the assistance. I went about it in two way to achieve the desire result.The two way are stated below.

Very greatful.

Mem.SETRANGE(Mem.“User ID”,USERID);
Mem.SETFILTER(Mem.“Role ID”,’%1’,‘SUPER’);
IF NOT Mem.FINDFIRST THEN
BEGIN
usersetup.SETRANGE(usersetup.“User ID”,USERID);
usersetup.SETRANGE(usersetup.usereditable,TRUE);
IF NOT usersetup.FINDFIRST THEN
CurrForm.EDITABLE(FALSE)

//ERROR(You 1% cannot edit this form,USERID);
END

Mem.SETRANGE(Mem.“User ID”,USERID);
Mem.SETFILTER(Mem.“Role ID”,’%1’,‘SUPER’);
IF NOT Mem.FINDFIRST THEN
BEGIN
usersline.SETRANGE(usersline.“User ID”,USERID);
usersline.SETRANGE(usersline.allow,TRUE);
IF NOT usersline.FINDFIRST THEN
CurrForm.EDITABLE(FALSE)
{ ELSE
CurrForm.EDITABLE:=TRUE}

//ERROR(You 1% cannot edit this form,USERID);
END