cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in add sale opportunity stages di api

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member185682
Active Contributor
0 Kudos

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

former_member183402
Participant
0 Kudos

Hi all,

I tried to add more than one line in stages of opportunity but there is no luck, below are my codes (in PHP)

$oOpport->Lines->SetCurrentLine(0);
$oOpport->Lines->MaxLocalTotal=$Potentialamount;
$oOpport->Lines->StageKey=$Stageid;
$oOpport->Lines->SalesPerson=$Salesid;
$oOpport->Lines->DataOwnershipfield=$Ownerlinesid;
$oOpport->Lines->Add;

Error message is Notice: Trying to get property of non-object in C: Error: -5002

One line is added successfully but more than one line is not added.

Please anyone can help me