Skip to Content
avatar image
Former Member

Problem in add sale opportunity stages di api

Hi

Am trying to add new sale opportunity stages by using below code.

But it is updating existing row only.

If is there any wrong, please let me know.

Dim sales As SAPbobsCOM.SalesOpportunities = DirectCast(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSalesOpportunities), SAPbobsCOM.SalesOpportunities)


If sales.GetByKey(oOpportunity) Then
sales.Lines.SetCurrentLine(sales.Lines.Count - 1)
sales.Lines.PercentageRate = 100
sales.Lines.StageKey = 33
sales.Lines.StartDate = DateTime.Today
sales.Lines.ClosingDate = oDeliveryDate
sales.Lines.Add()

If sales.Update <> 0 Then
Dim error1 As String = oCompany.GetLastErrorDescription
show += error1
show += "');"
ScriptManager.RegisterStartupScript(Me, [GetType](), "Show", show, True)
End If

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Mar 23, 2017 at 01:16 AM

    Hi Nandappa,

    If this statements

    sales.Lines.PercentageRate = 100
    sales.Lines.StageKey = 33
    sales.Lines.StartDate = DateTime.Today
    sales.Lines.ClosingDate = oDeliveryDate
    

    should create a new stage, the correct code must be this:

    sales.Lines.SetCurrentLine(sales.Lines.Count - 1)
    sales.Lines.Add()
    sales.Lines.PercentageRate = 100
    sales.Lines.StageKey = 33
    sales.Lines.StartDate = DateTime.Today
    sales.Lines.ClosingDate = oDeliveryDate
    

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded