How to conditionally display the payment link?
When integrating with a payment provider using JustOn Cash Management, you can add the link to the relevant payment page to the invoice email or invoice PDF document, as described in Adding Link to Email or PDF.
However, you may want to display the link only on certain conditions, for example, only on invoices where the payment method is set Online Payment.
This requires
- A custom formula field that produces the payment link if there is an associated contact
- An allowlist entry for the custom formula field
- A custom placeholder for the formula field to included in the address field of your invoice template
Following the example, the configuration involves these steps:
-
Create the custom formula field
ShowPaymentPageURL(return typeText) on the Invoice object.Specify this formula:
IF (AND (TEXT(ONB2__Template__r.ONB2__Language__c) = 'de', TEXT(ONB2__PaymentMethod__c) = 'Online Payment'), 'Sie können ganz einfach über unsere Bezahlseite bezahlen - ' + ONB2__PaymentPageUrl__c,IF (AND (TEXT(ONB2__Template__r.ONB2__Language__c) = 'en', TEXT(ONB2__PaymentMethod__c) = 'Online Payment'), 'You can easily pay using our payment page - ' + ONB2__PaymentPageUrl__c,' '))This formula checks whether the template language is German or English and whether the payment method is set
Online Payment. If so, it returns the (locale-specific) introduction text together with the retrieved payment page URL. Otherwise, it leaves the field blank.Make sure to select
Treat blank fields as blanks. -
Allowlist the new formula field to make it accessible for custom placeholders.
For details, see Field Whitelist.
-
Create the custom placeholder
[ShowPaymentPageURL], setting it up to retrieve theShowPaymentPageURLfield on the invoice.For details, see Custom Placeholders.
-
Add the new placeholder to the intended text field of your invoice template.
Possible target text fields may be
Text 2orText 3for the PDF andEmail BodyorEmail HTML Bodyfor the email.Make sure to apply the placeholder filter
no-persistto the placeholder, like[ShowPaymentPageURL|no-persist]
Related information:
Handling Payment Page Links
How to selectively display a field on the PDF?