cancel
Showing results for 
Search instead for 
Did you mean: 

GetNewObjectKey

Former Member
0 Kudos

Hi, Im using SAP B1 2007 A SP01 PL 07.

I have some code that is performing Incoming Payments via the DI API and checking the result.

If the result is OK, then I'm getting the new object key and using it further in the code. See code snippet below.

I'm finding that sometimes I get a DocEntry from GetNewObjectKey that cannot possibly be for the Incoming Payment that has just been created. It seems to be pointing to an incomiong Payment that was generated by another app that is running (POS).

QUESTION: Does the GetNewObjectKey method return the last key generated by the specific instance of the DI or does it return the key of the last object created across all instances of the DI ??

Regards,

Ben

...

...

int IncomingPaymentDocEntry;

int res1 = payment.Add();

if (res1 < 0)

{

//Payment posting Failed - Get Reason

Success = false;

string ErrorReason = B1Connections.diCompany.GetLastErrorDescription();

LastSAPError = ErrorReason;

break;

}

else

{

//INCOMING PAYMENT GENERATED OK

//CREATE LINE IN @BK_INC_PYMT

IncomingPaymentDocEntry = int.Parse(B1Connections.diCompany.GetNewObjectKey());

nonGrainIncPaymentsTableAdapter.AddPaymentLine(NextRunNo, pcp.Project, Convert.ToDouble(pcp.Movement), Convert.ToDouble(pcp.NewBalance), pcp.Ref, IncomingPaymentDocEntry);

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

It is received the last added document entry by DI API of your addon.

I mean, if you add any Business Object inside your addon you can receive the last added key of your connection.

I am suggesting to use not equal instead of < in your code where you checking the result of Add procedure.

Regards

J

Answers (0)