cancel
Showing results for 
Search instead for 
Did you mean: 

Permission

Former Member
0 Kudos

Hi EveryBody

We have an add-on, and we would like to restrict the access or to hide menu of this add-on to specific user.

How we can do it ?

Thank you,

Regards

Jaggy

Accepted Solutions (1)

Accepted Solutions (1)

CRVMANISH
Contributor
0 Kudos

Hi

You may do it a bit professional, create user permisson as

oPermission = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserPermissionTree)

oPermission.Name = "Permission for form 1"

oPermission.PermissionID = "form1"

oPermission.UserPermissionForms.FormType = "f1"

oPermission.ParentID = "take here parrent id"

oPermission.Options = SAPbobsCOM.BoUPTOptions.bou_FullNone

RetVal = oPermission.Add()

oPermission = Nothing

GC.Collect()

after that in time when you are creating menus, you may cehck if user has this permission and if not, dont create menu

if hasright("form1") then

'create menu

end if

and hasright is as

Function hasright(ByVal permid As String) As Boolean

Dim result As Boolean = False

Dim orecset As SAPbobsCOM.Recordset

orecset = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

orecset.DoQuery("select superuser from ousr with(nolock) where superuser = N'Y' and userid = " & oCompany.UserSignature)

If orecset.RecordCount > 0 Then

result = True

End If

'isnt super user, i must test user rights

If result = False Then

orecset.DoQuery("select userlink from usr3 with(nolock) where PermId = N'" & permid & "' and (permission = 'F' ) and userlink = " & oCompany.UserSignature)

If orecset.RecordCount > 0 Then

result = True

End If

End If

orecset = Nothing

GC.Collect()

Return result

End Function

Now you can set user permissions in permission tree in sbo form and will be not hardcoded.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Jaggy,

You may restrict such users in the license for add-on. Just do not assign license for add-on to them.

Thanks,

Gordon

Former Member
0 Kudos

Thanks Manish & Gordon for reply,

I manipulated the code, now it work. This is indeed a great help