cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove Draft Documents using DIAPI?

Former Member
0 Kudos

DIAPI help says that Remove Method is not supported because "SAP Business One does not allow to remove a document object from the database".

However, in SBO UI, you can remove Draft Documents. Is there another way or workaround in DI API for deleting Draft Documents?

Juha

Accepted Solutions (1)

Accepted Solutions (1)

AlexGrebennikov
Active Contributor

Juha, why do you think so?

The following snippet shows you how to kill Purchace-draft:

SAPbobsCOM.Documents oDraft;
oDraft = (SAPbobsCOM.Documents)pCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);

oDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oPurchaseInvoices;
oDraft.GetByKey(<DraftDocEntry>);
resCmpTo = oDraft.Remove();
if (resCmpTo != 0)
{
	pCmp.GetLastError(out errNum, out errStr);
	MessageBox.Show("oDraft.Remove(): " + errNum.ToString() + "n" + errStr);
}

HTH

Answers (0)