cancel
Showing results for 
Search instead for 
Did you mean: 

How to use user defined object in SAP B1 SDK?

former_member183402
Participant

Hi all,

Actually I use below code in php which is fine

$oOrder=$mycomp->GetBusinessObject(22);

But now I want to connect to user defined object called OALW, I tried to replace 22 with OALW like below

$oOrder=$mycomp->GetBusinessObject("OALW");

but I'm getting the following error message Fatal error: Uncaught com_exception: Parameter 0: Type mismatch. in C:\xampp\htdocs\sap\allowance.php:23 Stack trace: #0 C:\xampp\htdocs\sap\allowance.php(23): com->GetBusinessObject('OALW')

How can I use user defined object in GetBusinessObject() in order to update its table?

Accepted Solutions (1)

Accepted Solutions (1)

PierreBrothier
Contributor

Hi,

to work with UDO, you should user GeneralService object and GeneralData.

I don't have any php sample, but you can use the following visual basic sample for inspiration :

It cames from SAP Business one SDK help center

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)
former_member183402
Participant
0 Kudos

Thank you Pierre

Answers (1)

Answers (1)

0 Kudos

Hello,

It,s Work through UDO Process Creation.