HideIf, the Consultant’s Best Friend
All APIs have their quirks and require different logic. With the HideIf function, you can easily bypass certain mappings in a smooth and efficient way.
Example 1
You need to create an invoice based on accounting lines from another system. When you fetch the lines, you receive a complete accounting in your Array:
- Accounts Receivable 151x
- Revenue Account 30xx
- VAT Account 24xx
From the accounts receivable account, you want to use some information, but you don’t want to create an invoice line for it.
"invoiceLines": [
{
"=ArrayMap": "$.Group[*]",
"=HideIf": "@.Account = '1510'",
This lets you process all the lines, but will hide any line where Account = 1510.
Example 2
On the same invoice, you have several lines with revenues that need to go to different accounts. For some of the lines, you have a periodization key and want to use the start and end dates from the invoice header to control the periodization. When you map, all lines get start and end dates, but the API might not like it if you’re missing a periodization key.
"termStartDate": {
"=HideIf": "@.Depr_key = ''",
"value": "@.Invoice_date"
},
"termEndDate": {
"=HideIf": "@.Depr_key = ''",
"value": "@.Due_date"
},
This means certain fields will not be included if the condition is met—that is, if the row is missing a periodization key.
Example 3
In some cases, the invoice does not balance out and you need to map a hard-coded line. But you don’t want this line included every time, only when it’s needed.
"=HideIf": "Sum($.Group[*].Amount) = 0",
This ensures that your hard-coded line will not be included if the sum of the amounts in your array is 0—in other words, if the invoice balances.