Skip to content

How to force JustOn to create new PDF files for multiple invoices?

In certain cases (like layout errors, text typos etc.) you may have to recreate the PDF files for all invoices of a particular invoice run. To this end, you successively execute the following commands in the Execute Anonymous Apex tool of the Developer Console, applying your details (<id>).

  1. Find and delete all existing PDF files.

    1. Up to JustOn 2.48 (PDF in Notes & Attachments):
    SELECT Id FROM Attachment WHERE ParentId IN (SELECT Id FROM ONB2__Invoice__c WHERE ONB2__InvoiceRun__c = '<id>') AND ContentType = 'application/pdf' AND Description = 'bill.ON PDF' ORDER BY ParentId ASC NULLS FIRST
    
    1. As of JustOn 2.49 (PDF in Files):
    SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId IN (SELECT ID FROM ONB2__INVOICE__c WHERE ONB2__InvoiceRun__c = '<id>')
    
  2. Clear the PDF field on the invoice records.

    SELECT Id,ONB2__PDF__c FROM ONB2__Invoice__c WHERE ONB2__InvoiceRun__c = '<id>' AND ONB2__PDF__c != null ORDER BY ONB2__Account__c ASC NULLS FIRST
    
  3. Download the CSV file, and replace https://.+ with #N/A.

  4. Update the invoices with the Apex Data Loader.

    Use the batch size 100 and the serial processing mode.

  5. In the corresponding invoice run detail view, click Set to Open to invoke the PDF regeneration.

Info

If you need to recreate a single invoice PDF, refer to How to force JustOn to create a new PDF for a single invoice?.