Skip to Content

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

Formsettings on Invoice Form, FormPreferencesService

Hi Everyone

Im trying to use formsettingspreference to set what columns will be visible in the matrix in the invoice form. The below code works only if sbo is closed, once you log on you can see the changes, i'm doing it through the DI API.

My problem is that i'm not sure which values to use for the columns id's. Below i use 24 which is the columnid of "warehouse column" in the front end of sbo, but when i run the code it makes "Gross Profit (LC)" visible and not the warehouse column. Which number must i use? Where can i get all the columns id numbers?

Has anyone used this new functionality yet? What numbers must i use for column id?

Dim FormSettingsService As SAPbobsCOM.FormPreferencesService

Dim ColumnSettingsData As SAPbobsCOM.ColumnsPreferences

Dim ColumnSettingsPara As SAPbobsCOM.ColumnsPreferencesParams

oCompanyService = oCompany.GetCompanyService

FormSettingsService = oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.FormPreferencesService)

ColumnSettingsPara = FormSettingsService.GetDataInterface(SAPbobsCOM.FormPreferencesServiceDataInterfaces.fpsdiColumnsPreferencesParams)

ColumnSettingsPara.FormID = "133"

ColumnSettingsPara.User = 1

ColumnSettingsData = FormSettingsService.GetColumnsPreferences(ColumnSettingsPara)

ColumnSettingsData.Item(24).EditableInForm = SAPbobsCOM.BoYesNoEnum.tYES

ColumnSettingsData.Item(24).VisibleInForm = SAPbobsCOM.BoYesNoEnum.tYES

FormSettingsService.UpdateColumnsPreferences(ColumnSettingsPara, ColumnSettingsData)

Thanks in advance

Former Member
Former Member replied

I have just tried this object for the first time and have to say I found the choice of index value to the item collection to be rather strange and not very useful.

Basically where you have used (24) as the index, which is the logical choice, SAP have instead chosen it to be indexed by an internal row counter. In my database this lead to column "24" actually being index 110.

A loop through the columnsettingsdata can easily find the correct column, but is highly inefficient.

For lngCount = 0 To ColumnSettingsData.Count - 1
    If ColumnSettingsData.Item(lngCount).Column = "24" Then
        ColumnSettingsData.Item(lngCount).EditableInForm = SAPbobsCOM.BoYesNoEnum.tNO
        ColumnSettingsData.Item(lngCount).VisibleInForm = SAPbobsCOM.BoYesNoEnum.tYES
        Exit For
    End If

The help file lists the index value as a variant, but it won't accept strings. Personally I think it should accept the columnUID as a string value as this would be the most logical way to access it for a B1 developer.

I have still to try out the XML interface, hopefully that will be a lot easier to use.


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