cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if SAPbobsCOM.Documents object represents draft?

0 Kudos
1,315

Hi folks,

I get the draft invoice in this way:

SAPbobsCOM.Documents oDoc = Company.GetBusinessObject( SAPbobsCOM.BoObjectTypes.oDrafts );
oDoc.GetByKey( docEntry );

Now, I want to check if object oDoc represetns draft or regular document.

After method GetByKey() property DocObjectCodeEx (and DocObjectCode too) return value 13 (and oInvoice).

m_felicella
Participant
View Entire Topic
vitor_vieira
Explorer
0 Kudos

Hi Przemyslaw,

I see the issue. Never came across this scenario myself.

Do you at least know if all the documents are based on a Draft? If they do, you can use the 'draftkey' property to distinguish the - all Drafts have draftkey = -1 and all documents based on a draft will have a value other than -1. Again, this logic will only work if you know for sure all the documents are based on Drafts.

Hope it helps,

Vitor

Hi Vieira,

I dont know nothing about documents I get - that the point. But You pushed my thoughts to solution, that is not optimal but works. I will try to create object with the same ObjType and DocEntry as the object from array has. If it fails = this was draft.

bool IsDraft( SAPbobsCOM.Documents oUnknownDocument )
{
    SAPbobsCOM.Documents oTestDocument = Company.GetBusinessObject( oUnknownDocument.DocObjectCode );
    return oTestDocument.GetByKey( oUnknownDocument.DocEntry );
}