📚 SAP Business One SDK Help

Add Method
See Also  Example
pIGeneralData
The data for the new row.

Description

Adds a row to the database table of the current UDO.

The data for the row is contained in the GeneralData object passed to the method.

Syntax

Visual Basic
Public Function Add( _
   ByVal pIGeneralData As GeneralData _
) As GeneralDataParams

Parameters

pIGeneralData
The data for the new row.

Return Type

The key of the new row.

Example

Adding a UDO record (Visual Basic)Copy Code
Dim oGeneralService As SAPbobsCOM.GeneralService
Dim oGeneralData As SAPbobsCOM.GeneralData
Dim oSons As SAPbobsCOM.GeneralDataCollection
Dim oSon As SAPbobsCOM.GeneralData

Dim sCmp As SAPbobsCOM.CompanyService
sCmp = oCompany.GetCompanyService

'Get a handle to the SM_MOR UDO
oGeneralService = sCmp.GetGeneralService("SM_MOR")

'Specify data for main UDO
oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)
oGeneralData.SetProperty("U_Room", "1")
oGeneralData.SetProperty("U_Price", "20")
oGeneralData.SetProperty("U_Name", "David")

'Specify data for child UDO
oSons = oGeneralData.Child("SM_MOR1")
oSon = oSons.Add
oSon.SetProperty("U_MainDish", "Chicken")
oSon.SetProperty("U_SideDish", "Fries")
oSon.SetProperty("U_Drink", "Cola")

'Add records
oGeneralService.Add(oGeneralData)

See Also