action.skip

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

← PDF and Email FAQ

In certain cases you may have to recreate the PDF files for multiple invoices that match certain criteria, like those of a particular invoice run or those produced on a certain date. To this end, you successively execute the following commands in the Execute Anonymous Apex tool of the Developer Console, applying your particular search criteria in an SOQL WHERE clause.

Example use cases and WHERE clauses
WHERE Clause Use Case
WHERE ONB2__InvoiceRun__c = '<id>' Retrieves invoices of a particular invoice run (specified by its ID).
WHERE ONB2__Date__c = '<date>' Retrieves invoices of a particular date.
WHERE ONB2__Class__c = 'Credit' Retrieves all credits.

Note

Your use case may require different search criteria. Make sure to adjust the WHERE clause according to your needs.

  1. Find and delete all existing PDF files.

    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

    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 Finalize 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.