Welcome Notes

Welcome Viewers

12 March 2018

Add user Permission to Form through SDK

Dear All,
   Today , We will see, How to Add user Permission to Form through SDK


 Public Function AddUserPermissionTree(ByVal strPermissionId As String, ByVal strName As String, ByVal strMode As SAPbobsCOM.BoUPTOptions, ByVal intLevel As Integer, ByVal strFatherId As String) As Boolean
        '**********************************************
        '' DECLARE LOCAL VARIABLE(S)
        '**********************************************
        Dim li_RetVal As Integer = 0
        Dim pUserPer As SAPbobsCOM.UserPermissionTree = Nothing
        Dim blnReturn As Boolean = False
        '**********************************************
        oApp = New ClsSAPConn
        pUserPer = oApp.SAPCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserPermissionTree)
        '**********************************************
        Try
            If pUserPer.GetByKey(strPermissionId) = False Then
                pUserPer.PermissionID = strPermissionId
                pUserPer.Name = strName

                pUserPer.Options = strMode
                li_RetVal = pUserPer.Add()
                If li_RetVal <> 0 Then
                    blnReturn = False
                Else
                    blnReturn = True
                End If
            Else
                pUserPer.Name = strName
                pUserPer.Options = strMode
                li_RetVal = pUserPer.Update()
                If li_RetVal <> 0 Then
                    blnReturn = False
                Else
                    blnReturn = True
                End If
            End If
        Catch ex As Exception
            blnReturn = False
        Finally
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pUserPer)
            If oApp IsNot Nothing Then
                oApp = Nothing
            End If
        End Try
        Return blnReturn
    End Function