Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Permission

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

Former Member
replied

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.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question