Skip to Content
0

Are the any other option by GetNewObjetKey to retrieves the key of the last added record?

Apr 30 at 08:19 AM

17

avatar image
Former Member

We have customer that use few AddOns and processes that add new documents via DI API. We found that sometimes 2 transactions (documents) added almost stimulatingly and we get the same object key for these both transactions. So we don't have the correct object for one of the documents.

Follow the example of code that we use (we run it for different objects on the same company connection):

SAPbobsCOM.Documents PurchaseOrder = Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders) as SAPbobsCOM.Documents;

PurchaseOrder.carcode= "123";

PurchaseOrder.DocRate = 3.5;

PurchaseOrder.DocDate =DateTime.Now;

PurchaseOrder.Lines.SetCurrentLine(0);

PurchaseOrder.Lines.ItemCode= "345";

PurchaseOrder.Lines.UnitPrice = 200;

int r = PurchaseOrder.Add();

if (r==0) {int result=Company.GetNewObjetKey();}

Are the any other option to retrieves the key of the last added record, may be by object type? or as the output of the Add method?

Regards

Tanya

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers