Create conditional expressions
You can create more than one active version of an invoice template per locale, and use conditional expressions to determine which fields appear on a version of an invoice template.
You can only use conditional expressions in templates that you create or that you copy from a marketplace-provided default template. You cannot add conditional expressions to marketplace default templates.
This topic describes how to add a conditional expression to a JSON template. For information about creating and editing JSON templates, see the topics in the Invoice template JSON introduction section.
Following are examples of how Resellers can use conditional expressions to manage JSON invoice template content using multiple versions of an invoice template:
Condition type | Conditions |
---|---|
Invoice status | If an invoice is unpaid, the Amount due field appears on the unpaid invoice. If an invoice is paid, the Amount due field does not appear. |
Country | Tax information changes depending on the user’s country. |
To add a conditional expression to a JSON template
📝 Note: If the AppDirect logo appears in the upper-left corner of the page, when Manage > Marketplace appears in this topic, click the grid icon > Switch to | Store, instead.
- Go to Manage > Reseller > Settings >Billing Settings | Invoice templates. The Invoice Templates listing page opens.
- Click the gear icon next to the template you want to edit, then select Edit JSON from the drop-down list.
- Add one or more conditional expressions, as required.
Sample conditional expressions
Conditional expressions can consist of a single condition or multiple conditions. Following are generic examples of conditional expressions for single and multiple conditions:
Single condition
{
"components": [
{
"data": "",
"description": "",
"style": {
"width": "100%",
"font-size": "6pt"
},
"isConditional": true,
"type": "markdownText",
"conditionalExpr": {
"condition": {
"operator": "ValueOf",
"key": "{{Invoice Status}}"
},
"effects": {
"UNPAID": {
"update": {
"data": "**WIRE PAYMENT INSTRUCTIONS** \nABC Bank \nNew York \nCredit: XYZ Digital Inc. \n**REFERENCE: {{Invoice Number}}**"
},
"type": "update"
}
}
}
}
],
"description": "",
"type": "cell",
"properties": {
"visible": true,
"position": "right",
"selected": false
}
}
Multiple conditions
{
"components": [
{
"data": "INVOICE \n**{{Invoice Number}}**\n\nAMOUNT DUE \n**{{Balance Due}}**\n\nINVOICE DATE \n**{{Date}}**\n\nDUE DATE \n**{{Invoice Due Date}}**",
"description": "Invoice Summary",
"style": {
"background-color": "#EAEAEA"
},
"type": "markdownText",
"isConditional": true,
"conditionalExpr": {
"condition": {
"operator": "AND",
"values": [
{
"operator": "Bool",
"key": "{{isCreditNote}}",
"value": "true"
},
{
"operator": "StringEquals",
"key": "{{invoiceStatus}}",
"value": "PAID"
}
]
},
"effects": {
"true": {
"update": {
"data": "CREDIT NOTE \n**{{Invoice Number}}**\n\nAMOUNT DUE \n**{{Balance Due}}**\n\nCREDIT NOTE DATE \n**{{Date}}**\n\nDUE DATE \n**{{Invoice Due Date}}**"
},
"type": "update"
},
"false": {
"update": {
"data": "INVOICE \n**{{Invoice Number}}**\n\nAMOUNT DUE \n**{{Balance Due}}**\n\nINVOICE DATE \n**{{Date}}**\n\nDUE DATE \n**{{Invoice Due Date}}**"
},
"type": "update"
}
}
}
}
],
"type": "cell",
"properties": {
"visible": true,
"selected": false
}
}
Was this page helpful?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!