cancel
Showing results for 
Search instead for 
Did you mean: 

What is the key of A/P Invoice Draft

Former Member
0 Kudos

Hi, all,

I want to update a Draft document of A/P Invoice, but I have no idea what is the Key Code.

Here is my code:

Dim oDoc As SAPbobsCOM.Documents

oDoc = oCompany.GetBusinessObject(BoObjectTypes.oDrafts)

oDoc.DocObjectCodeEx = BoObjectTypes.oInvoices

oDoc.GetByKey( ????? )

I tried to use DodNum, but can't get the right record.

Please advise.

Thanks

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Dear hkcm,

Yes you need to copy field by field.

Best Regards

Jane Jing

Former Member
0 Kudos

Hi, Jane,

Thanks for your reply.

Would you please tell me how to copy the draft to Invoice?

Can it be copied by a recordset, or I need to copy field by field?

After I copy the draft to Invoice, is the Draft document retained in the database?

Thanks

Former Member
0 Kudos

U need to copy field by field. After the new invoice from the draft is added u can Remove the draft by using oDraft.Remove()

U need to copy the fields as follows..

oInvoice.DueDate = oDraft.DueDate
oInvoice.CardCode = oDraft.CardCode
...
....

Vasu Natari.

Former Member
0 Kudos

Dear hkcm,

You need to create a new Invoice document, copy the date from draft to invoice then add the invoice.

Best Regards

Jane Jing

Former Member
0 Kudos

Thanks all,

I can loaded the Draft document and modify the content with oDoc.Update.

How to Add (Save) the Draft as offical AP Invoice?

I've tried oDoc.Add but didn't work.

Pls adv., thanks.

Former Member
0 Kudos

Dear hkcm,

Please use DocEntry property for oDoc.GetByKey method.

You could use following query to get the DocEntry of a draft



SELECT DocEntry, *  FROM odrf

Best Regards

Jane Jing

SAP Business One Forums team

Former Member
0 Kudos

Hi,

In the getbykey u need to pass the DocEntry.

Vasu Natari.

Former Member
0 Kudos

HI,

Dim oDoc As SAPbobsCOM.Documents

oDoc = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts)

oDoc.DocObjectCode = SAPbobsCOM.BoObjectTypes.oInvoices

oDoc.GetByKey()

for DRAFT=112

for INVOICES=13

regards,

varma