📚 SAP Business One SDK Help

GetNew ObjectType Method
See Also  Example

Description

Gets the last added object type.

Syntax

Visual Basic
Public Function GetNewObjectType() As String

Remarks

After the global flag EnableApprovalProcedureInDI is turned on, we strongly recommend that you call this method each time you add any document or payment to make sure that your Documents(Payments) have been added as Document(Payment) or Draft(PaymentDraft).

Example

Adding an invoice that needs approval (C#)Copy Code
' Preconditions: Approval template should be set in order to make every invoice pass approval process. 
Dim dockey As String = String.Empty 
Dim docType As String = String.Empty 
Dim oInv As SAPbobsCOM.Documents = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices) 
 
oInv.CardCode = "BP1" 
oInv.DocDate = Date.Today 
 
oInv.Lines.ItemCode = "Item1" 
oInv.Lines.Quantity = 2 
oInv.Lines.Price = 5 
oInv.Lines.TaxCode = "tx001" 
 
 
' This call must be done after all properties were filled 
' User can change remark if they need 
 
' Fill Approval Request sub object 
oInv.GetApprovalTemplates() 
oInv.Document_ApprovalRequests.Remarks = "Some Remarks for approval" 
 
Dim ret As Integer 
'Invoice was added as draft 
ret = oInv.Add() 
 
If ret = 0 Then 
    'Get new added object key and type 
    dockey = oCompany.GetNewObjectKey() 
    docType = oCompany.GetNewObjectType() 
End If

See Also