Create Budget

Top  Previous  Next

[Visual Basic] The following example demonstrates how To create And save a New Budget entity. (This example uses the BudgetWebService.)

 

' ----------------------------------------

' Step 1: Create an instance of the web service.

' ----------------------------------------

Dim budgetWs As New WebServices.BudgetWebService("http://localhost/objacctwebservices/")

 

' ----------------------------------------

' Step 2: Set the LoginKey. (Use Login.GetLoginKey to

' login to a specific company and generate a LoginKey.)

' For this example, the LoginKey is being stored in a

' public variable called PublicLoginKey.

' ----------------------------------------

WebServices.SoapHeader.SetLoginKey(budgetWs, PublicLoginKey)

 

' ----------------------------------------

' Step 3: Create and populate a DataSet with the new entity.

' For this example, we're creating a new Budget entity, so we

' will use the ObjAcct.WebServices.DataSets.BudgetDataSet.

' ----------------------------------------

Dim budgetDs As DataSet = New WebServices.DataSets.BudgetDataSet()

 

' -----------------

' Budget Entity.

' -----------------

Dim entityDr As DataRow = budgetDs.Tables("Entity").NewRow

 

entityDr("RowID") = ""

entityDr("AccountRowID") = "10.0"

entityDr("ClassRowID") = "17.0"

entityDr("EmployeeRowID") = "2.0"

entityDr("FiscalYear") = Now.Year.ToString

entityDr("Type") = "C"                ' Current Budget.

 

' Budget ID is combination of Fiscal Year, Account, Class, and Type.

entityDr("BudgetID") = entityDr("FiscalYear") & entityDr("AccountRowID") & entityDr("ClassRowID") & Trim(entityDr("Type"))

 

entityDr("Period01Amount") = 1200

entityDr("Period02Amount") = 1200

entityDr("Period03Amount") = 1200

entityDr("Period04Amount") = 1200

entityDr("Period05Amount") = 1200

entityDr("Period06Amount") = 1200

entityDr("Period07Amount") = 1200

entityDr("Period08Amount") = 1200

entityDr("Period09Amount") = 1200

entityDr("Period10Amount") = 1200

entityDr("Period11Amount") = 1200

entityDr("Period12Amount") = 1200

 

' Add the row to the Entity table.

budgetDs.Tables("Entity").Rows.Add(entityDr)

 

' ----------------------------------------

' Step 4: Save the entity.

' ----------------------------------------

Dim returnDs As DataSet = budgetWs.SaveEntity(budgetDs)

 

' Check for errors.

If StdLib.GetErrorNumber(returnDs) < 0 Then

       MsgBox(StdLib.GetErrorAsString(returnDs))

End If