📚 SAP Business One SDK Help

UserPermissionTree Object
See Also  Members  Example

Description

UserPermissionTree is a business object that represents the User Authorization Form. This object enables to manage user authorization for new forms (which their FormType property is defined in UserPermissionForms object).

After adding a user permission tree to the Authorizations tree, you can set the UserPermission object.

This object enables you to:

  • Add a user permission tree to the Authorizations tree.
  • Retrieve a user permission tree by its key.
  • Update a user permission tree.
  • Remove a user permission tree from the Authorizations tree.
  • Save the object in XML format.

Source table: OUPT.

Object Model












Remarks

Mandatory field in SAP Business One: PermissionId.

To display the form in the application:

  • Select Administration --> System Initialization --> Authorization --> User Authorization Form.

See example of User Authorization Form.

To manage user authorization for forms that are not forms, set the mUserPermission.IsItem = tYES and create the logic to support the item permission.

Example

Adding a PermissionTree - parent object (Visual Basic)Copy Code
[Visual Basic]

Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim mUserPermission As SAPbobsCOM.UserPermissionTree
Set mUserPermission = oCompany.GetBusinessObject(oUserPermissionTree)

'//Mandatory field, which is the key of the object.
'//The partner namespace must be included as a prefix followed by _
mUserPermission.PermissionId = "SM_MathClass"

'//The Name value that will be displayed in the General Authorization Tree
mUserPermission.Name = "SM_MathClass"

'//The permission that this object can get
mUserPermission.Options = bou_FullReadNone

'//In case the level is one, there Is no need to set the FatherID parameter.
mUserPermission.Levels = 1
RetVal = UserPermission.Add
oCompany.GetLastError RetVal, ErrMsg
'//In case this permission object has a son permission object











Adding a PermissionTree - child object (Visual Basic)Copy Code
[Visual Basic]

Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim mUserPermission As SAPbobsCOM.UserPermissionTree
Set mUserPermission = oCompany.GetBusinessObject(oUserPermissionTree)

mUserPermission.PermissionId = "SM_MathClassSon"
mUserPermission.Name = "SM_MathClassExam"
mUserPermission.Options = bou_FullNone

'//For level 2 and up you must set the object's father unique ID
mUserPermission.Levels = 2
mUserPermission.FatherID = "SM_MathClass"
'//this object manages forms
mUserPermission.UserPermissionForm.FormType = "GL_MathClass"

RetVal = mUserPermission.Add
oCompany.GetLastError RetVal, ErrMsg


[Visual Basic]

Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim mUser As SAPbobsCOM.Users

Set mUser = oCompany.GetBusinessObject(oUsers)

'//The user unique ID is 2
RetVal = mUser.GetByKey(2)

'//Setting a new sub object for the User that hold the user permission for the user permission object
mUser.UserPermission.PermissionId = "SM_MathClassSon"

'//Seting full permission for User 2 to manage SM_MathClassSon sub object
mUsers.UserPermission.Permission = boper_Full

RetVal = mUsers.Update
oCompany.GetLastError RetVal, ErrMsg
Setting user permission (Visual Basic)Copy Code
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim mUser As SAPbobsCOM.Users

Set mUser = oCompany.GetBusinessObject(oUsers)

'//The user unique ID is 2
RetVal = mUser.GetByKey(2)

'//Setting a new sub object for the User that hold the user permission for the user permission object
mUser.UserPermission.PermissionId = "SM_MathClassSon"

'//Seting full permission for User 2 to manage SM_MathClassSon sub object
mUsers.UserPermission.Permission = boper_Full

RetVal = mUsers.Update
oCompany.GetLastError RetVal, ErrMsg

See Also