cancel
Showing results for 
Search instead for 
Did you mean: 

DI: Salesorder GetByKey

frank_toth
Explorer
0 Kudos

Hello,

a obviously simple task, but somehow it is not working:

After the user has successfully saved a sales order I'm trying to get the sales order document with the document number from the form (cust_order_no as Integer):

Dim oOrder As SAPbobsCOM.Documents

oOrder = company.GetBusinessObject (SAPbobsCOM.BoObjectTypes.oOrders)

ret = oOrder.GetByKey(cust_order_no)

GetByKey returns false although the order is in the database.

What is wrong?

DI API 6.7

Regards,

Frank

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The order number displayed on the form is not the key.

The order number displayed on the form maps to the field "DocNum", the key field is "DocEntry". DocEntry is always sequentially generated by the system, whereas DocNum can optionally be manually entered.

John.

Former Member
0 Kudos

Thanks John,

So what you're telling us is essentially this:

1) retrieve docnum through UI-api

2) query database for correct docentry for given docnum

3) retrieve document-object through a getbykey

Regards,

Jacques

Former Member
0 Kudos

It can get even more interesting than that if you are dealing with adding new documents.

"retrieve docnum through UI-api" sounds rather easy. You need to remember that the DocNum displayed on screen while you are entering an order isn't necessarily the docnum that ends up on the sales order when you add it.

Potentially if you are using automatically generated numbers, another user may have added a new sales order while you were typing the details into the screen. Their order would have the same DocNum as yours displayed when they were entering it, and would get that number allocated to their order when they saved it. When you save your order, business one will allocate the next available docnum from the series and it will then display a message in the status bar telling you the actual document number it used.

Make sure you watch out for that one.

Regards,

John.

frank_toth
Explorer
0 Kudos

Thank you John, so I have to look for this because I just get the docnum from the order form as Jaques described.

Regards,

Frank

former_member374
Active Contributor
0 Kudos

Hi Frank,

You are thanking a poster for his answer.

Please next time also give him points.

See: /people/mark.finnern/blog/2004/08/10/spread-the-love

This time I did it for you.

Remember: When you ask a question you also assume the responsibility to assign points.

Please check your other questions and if the answers were good.

Spread the love and give some points.

Thanks in advance, Mark.

Answers (0)