📚 SAP Business One SDK Help

UpdateColumnsPreferences Method
See Also  Example
pIColumnsPreferencesParams
Returns the data structure that specifies the identification key combination (user and form) of the Form Preferences.
pIColumnsPreferences

Returns the data structure that specifies the data for update the Form Preferences.

Description

Updates the column preferences of a specified form for a specified user with the data specified in ColumnsPreferences data structure.

Syntax

Visual Basic
Public Sub UpdateColumnsPreferences( _
   ByVal pIColumnsPreferencesParams As ColumnsPreferencesParams, _
   ByVal pIColumnsPreferences As ColumnsPreferences _
) 

Parameters

pIColumnsPreferencesParams
Returns the data structure that specifies the identification key combination (user and form) of the Form Preferences.
pIColumnsPreferences

Returns the data structure that specifies the data for update the Form Preferences.

Example

The following is a VB.NET sample that updates the width of all the visible items in the invoice form settings.
UpdateColumnPreferences (Visual Basic)Copy Code
Dim oCmpSrv As SAPbobsCOM.CompanyService
Dim oFormPreferencesService As FormPreferencesService
Dim oColsPreferences As ColumnsPreferences
Dim oColPreferencesParams As ColumnsPreferencesParams
Dim i As Integer

'get company service
oCmpSrv = oCompany.GetCompanyService

'get Form Preferences Service
oFormPreferencesService = oCmpSrv.GetBusinessService(ServiceTypes.FormPreferencesService)

'get Columns Preferences Params
oColPreferencesParams = oFormPreferencesService.GetDataInterface(FormPreferencesServiceDataInterfaces.fpsdiColumnsPreferencesParams)

'set the form id (e.g. A/R invoice=133)
oColPreferencesParams.FormID = "133"

'set the user id (e.g manager= 1)
oColPreferencesParams.User = 1

'get the Columns Preferences according to the formId & user id
oColsPreferences = oFormPreferencesService.GetColumnsPreferences(oColPreferencesParams)

'change the width of all the visible items
For i = 0 To oColsPreferences.Count - 1
    'check if the item is visible
    If oColsPreferences.Item(i).VisibleInForm = BoYesNoEnum.tYES Then
        'set the width of the item
        oColsPreferences.Item(i).Width = 100
    End If
Next

'update all changes
oFormPreferencesService.UpdateColumnsPreferences(oColPreferencesParams, oColsPreferences)

See Also