How to delete existing item codes from Item Catalog

We have a set of codes that we don’t required anymore that need to be deleted or deactivated to avoiding users use them in error. Please can you advise how this can be achieved?

Hello Lili. In order to delete a part permanently you’ll need to query for the ID, then delete the part from all billing transactions, invoices, transactions, shipments, estimates, stocked products, and product history. If the part is also re-rented then you’ll need to modify the code below to first delete the re-rented parts, then traverse the items again using the ID without the re-rent owner ID.

First, start with the sample C# project on this site, add your login credentials and use the code below as a sample.

To get the part, use the Product. Sample C# code below.

        // Get part number
        Product prod = Product.GetProduct("PARTNUMBER", ProductType.Product);
        Guid productID = prod.ProductID;

        // Billing transactions
        BillingTransactionCollection trans = BillingTransactionCollection.GetBillableTransactionsCollection();
        foreach (BillingTransaction tran in trans)
            if (tran.BaseProductID == productID)

        InvoiceList invoices = InvoiceList.GetInvoiceList(InvoiceExportStatus.All);
        foreach (InvoiceListItem inv in invoices)
            Invoice theInvoice = Invoice.GetInvoice(inv.InvoiceID, false);
            foreach (InvoiceRentProduct rProd in theInvoice.InvoiceRentProducts)
                if (rProd.BaseProductID == productID)

        // Same for transactions, estimates, shipments, product history
        // ...


I was given these codes from Lili and would like to get further assistance in executing it. Currently I am having an exception when processing line:
Invoice theInvoice = Invoice.GetInvoice(inv.InvoiceID, false);

The error is:
An unhandled exception of type ‘Avontus.Core.DataPortalException’ occurred in Avontus.Core.dll

Additional information: DataPortal.Fetch failed (Validation rule rule://Avontus.Rental.Library.StockingLocation/DefaultRateProfileIDRequired/DefaultRateProfileID failed in property DefaultRateProfileID)

Please advise, thank you.


Hillo Christiano. Are you able to edit the invoice in the UI without any issue? Are you getting the exception on one invoice or all of them?

Hi there,

I don’t know whether such invoice editable in the UI (nor this error applied to other invoices). I could ask the user to try opening the invoice however my assumption is if the invoice could get in then it should have passed the validations.


You’ll have an easier time troubleshooting if you have access to the Quantify data that you’re looking at through the API.