Working with variables
LoanPro makes loan and customer data available so that you can create individualized communications, such as forms, emails, payment receipts, rules, and computation fields that are customized for each loan or customer. This article will help you understand how to use these variables so you can maximize your use of the software.
To access a list of available variables in most places where rules or templates are created in the system, click "Help Variables" at the top right of the edit area.
You can use the search field to find variables you want to use. For most variables, you can click the Help Variable ID to insert the variable into the edit area at the position where the cursor is located.
Single-value variables
Most variables are single-value variables. This means that the variable has one value per loan, customer, etc. For example, the variable ‘setup-loan-amount’ is the variable for loan amount, which is a single number. If you are using a variable with a template, you will typically enter it like this:
[[v(‘setup-loan-amount’)]]
The double brackets tell our template generator to look at the text as something more than just plain text. The v() is the variable function, which tells the template generator that you want to find a variable and replace it with an appropriate value. The ‘setup-loan-amount’ piece is the ID of the specific variable.
Because templates are for display, there are functions to help you format the data the variable is standing in for. For more information on using formatting functions, see the article on formatting functions.
If you are entering the variable into a rule, you are actually writing a Clojure (the language our rules service uses) script. This means you can enter the variable name straight in, in most cases (e.g. setup-loan-amount).
Date-range variables
Date Range is a category of variables. You can have this type of variable calculate and display a total over a specified date range. Several ranges are built in to the system, but you can also choose a custom range. The query() function is used in order to specify both the date and the date range.
Function name: query()
Parameter 1: Variable Property Name (required)
Parameter 2: Date Range String (required). Options include:
- date.range.all – This returns the sum for all dates.
- date.range.customDays – This lets you specify a custom date range in the past. You will be required to enter the number of days ago when the date range starts and the number of days ago when the date range stops as additional parameters. The larger number should be entered first.
- date.range.customFuture – This lets you specify a future date range starting with tomorrow up to a specified number of days over which the total will be calculated.
- date.range.customPast – This lets you specify a past date range starting with yesterday up to a specified number of days ago over which the total will be calculated.
- date.range.lastMonth – This will calculate a total for the last month.
- date.range.lastWeek – This will calculate a total for the last week.
- date.range.lastYear – This will calculate a total for last year.
- date.range.monthToDate – This will calculate a total for the current month to date.
- date.range.thisMonth – This will calculate a total for the current month.
- date.range.thisWeek – This will calculate a total for the current week.
- date.range.today – This will show the total for today only.
- date.range.yearToDate – This will calculate a total for the year to date.
- date.range.yesterday – This will show a total for yesterday only.
Parameter 3: A number of days. This option is only used for the date.range.customPast, date.range.customFuture, and date.range.customDays options.
Parameter 4: A number of days. This option is only used for the date.range.customDays option.
Example #1
If you would like to see the total paid last month, you should use the following date range variable with the query function: [[query(‘payments-total’, ‘date.range.lastMonth’)]].
Example #2
If you would like to see the total amount paid for the last 10 days, you should use the following date range variable with the query function: [[query(‘payments-total’, ‘date.range.customPast’, 10)]].
Example #3
If you would like to see the total amount paid over a date range that started five days ago and extends to 15 days ago, you should use the following date range variable with the query function: [[query(‘payments-total’, ‘date.range.customDays’, 5, 15)]].
Array-style variables
Some variables let you merge data for which there are multiple values. For example, if you wanted to merge the scheduled interest amount for a single payment into a form, you’d need to specify which payment you had in mind. Since there are multiple scheduled payments on a loan, this variable is an array-style variable (a variable that holds multiple values).

Array variables also contain all the data for a particular item or transaction. For example, if you want to include the payment amount from a scheduled payment in a form, you can search for Scheduled Payments and click the icon to the left of the variable name to view the data for this variable.
To insert the variable value for principal amount, click scheduled-payments.amount. This will insert the variable in this form: [[v(‘scheduled-payments.INDEX.scheduled-payments.amount-principal’)]]. Now, you simply need to replace INDEX with a numeric value for a specific payment like this: [[v(‘scheduled-payments.0.amount’)]]. This will actually show the values for the first scheduled payment because the indexes for array variables start at 0 instead of 1.
You can also use array variables inside of a loop. This means that you tell the template to go through every iteration of the array variable. For more information, see our article on template logic.
Example: collateral array variables
One example of an array variable is a collateral item. Since a single loan can be secured with up to 50 collateral items, it's necessary to distinguish which one you're referring to. Suppose, for instance, that a loan is secured with two cars, and you want to see the book value of each. Both are array variables of collateral; they are both nested within that central home. Here are the two variables you would use for either car's book value:
- [[v('collateral-position.id1.collateral-book-value')]]
- [[v('collateral-position.id2.collateral-book-value')]]
The variable starts with collateral-position, then a number indicating the position (which identifies a specific collateral item), and finally a specific field, book-value, within each collateral item. This tells LoanPro that you want to look at collateral, you want to see a specific collateral item, and you want it's book value. The position number is actually one that users can specify when they add collateral tracking to a loan; for other variables, like payments, the number is assigned automatically by the system.
Alternatively, suppose we want several variables referring back to the same collateral item. We would keep "collateral-position.id1." and then add the different fields at the back.
- [[v('collateral-position.id1.collateral-vin')]]
- [[v('collateral-position.id1.collaterallicense-plate')]]
For a full list of the array variables related to collateral, see our article on context engine glossary – collateral.
Loops
When you create loops, you can either surround the loop elements in double curly braces {{}} or double square brackets [[]]. You have the option to either loop commands either directly on the face of the template, or as HTML comments. On the face of the template, logic would look something like this:
[[BEGIN]] [[END]]
After the BEGIN command, we need to enter the name of the array variable we want to loop through:
[[BEGIN scheduled-payments]] [[END]]
Finally, we will enter what we want the form to display for each iteration of the variable. If we enter variable properties, they should be inside double square brackets:
[[BEGIN scheduled-payments]] [[amount]] [[END]]
The logic above will output the amount of each payment. If the payment amount is $500.00 and there are 5 payments, the output will be something like this:
1000
1000
1000
1000
1000
We can then add other things to help format the loop output. formatting functions don’t work exactly like usual in loops. When enter the logic on the face of the form, it can be hard to do things like build HTML tables. To do something like that, you can enter the BEGIN and END commands as HTML comments.
To do this, first click the HTML editor button. This will bring up a window where you can directly edit the HTML. Your commands as HTML comments should look like this:
<!– [[BEGIN scheduled-payments]] –>
<!– [[END]] –>
If you are trying to build a table on the form, the end result will look something like this:
You can see the comments in red. Click . Your form will look something like this:
This should output the following schedule:
Formatting functions with array-style variables
You can use formatting functions within array-style variables, but you have to include extra parameters for them to work. Currently only these formatting functions are supported:
- formatDateTime()
- companyFormatDateTime()
- formatNumber
The difference when using these functions inside a loop is that the first parameter is a variable property name instead of a variable name, there is a variable used to let the template service know which iteration of a variable it’s on, and there is an extra parameter of variable name.
- Function Name: formatDateTime()
- Parameter 1: Variable Property Name (required)
- Parameter 2: Format String (required)
- Parameter 3: Offset (required) – This is a string that lets you add or subtract time from dates.
- Parameter 4: $_num (required) – This is a variable the template engine uses to recognize the number of the variable iteration.
- Parameter 5: Variable Name (required) – The name of the variable the property of which is being used as Parameter 1.
The final function should look something like this: [[formatDateTime(‘date’, ‘m/d/Y’, ”, $_num, ‘scheduled-payments’)]].
Example Loan Payment Schedule:
<table><tbody>
<tr>
<th>Period</th>
<th>Payment Amount</th>
<th>Payment Date</th>
<th>Principal Remaining</th>
</tr>
<!–[[BEGIN scheduled-payments]]–>
<tr>
<td>[[period]]</td>
<td>$[[formatNumber('amount', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
<td>[[formatDateTime('date', 'm/d/Y', ", $_num, 'scheduled-payments')]]</td>
<td>$[[formatNumber('principal-balance', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
</tr>
<!–[[END]]–>
</tbody></table>
This example will iterate the scheduled payments on the loan from the loan transactions report, and will display a list of payment due dates and amounts. The example above would output something similar to the following formatted inside of a table using HTML:
Scheduled Payments:
Period Payment Amount Payment Date Principal Remaining
1 $439.58 10/01/2015 $4,602.09
2 $439.58 11/01/2015 $4,200.86
3 $439.58 12/01/2015 $3,796.29
4 $439.58 01/01/2016 $3,388.35
5 $439.58 02/01/2016 $2,977.01
6 $439.58 03/01/2016 $2,562.24
7 $439.58 04/01/2016 $2,144.01
8 $439.58 05/01/2016 $1,722.30
9 $439.58 06/01/2016 $1,297.07
10 $439.58 07/01/2016 $868.30
11 $439.58 08/01/2016 $435.96
12 $439.58 09/01/2016 $0.00
Note: When using loops inside of HTML tables, the [[BEGIN]] and [[END]] statements must be encapsulated in HTML comment tags. See above.
Function Name: companyFormatDateTime()
Parameter 1: Variable Property Name (required)
Parameter 2: Offset (required) – This is a string that lets you add or subtract time from dates.
Parameter 3: $_num (required) – This is a variable the template engine uses to recognize the number of the variable iteration.
Parameter 4: Variable Name (required) – The name of the variable the property of which is being used as Parameter 1.
The final function should look something like this: [[companyFormatDateTime(‘date’, ”, $_num, ‘scheduled-payments’)]].
Example Loan Payment Schedule:
<table><tbody>
<tr>
<th>Period</th>
<th>Payment Amount</th>
<th>Payment Date</th>
<th>Principal Remaining</th>
</tr>
<!–[[BEGIN scheduled-payments]]–>
<tr>
<td>[[period]]</td>
<td>$[[formatNumber('amount', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
<td>[[companyFormatDateTime('date', ", $_num, 'scheduled-payments')]]</td>
<td>$[[formatNumber('principal-balance', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
</tr>
<!–[[END]]–>
</tbody></table>
This example will iterate the scheduled payments on the loan from the loan transactions report, and will display a list of payment due dates and amounts. The example above would output something similar to the following formatted inside of a table using HTML:
Scheduled Payments:
Period Payment Amount Payment Date Principal Remaining
1 $439.58 10/01/2015 $4,602.09
2 $439.58 11/01/2015 $4,200.86
3 $439.58 12/01/2015 $3,796.29
4 $439.58 01/01/2016 $3,388.35
5 $439.58 02/01/2016 $2,977.01
6$439.58 03/01/2016 $2,562.24
7 $439.58 04/01/2016 $2,144.01
8 $439.58 05/01/2016 $1,722.30
9 $439.58 06/01/2016 $1,297.07
10 $439.58 07/01/2016 $868.30
11 $439.58 08/01/2016 $435.96
12 $439.58 09/01/2016 $0.00
Note: When using loops inside of HTML tables, the [[BEGIN]] and [[END]] statements must be encapsulated in HTML comment tags. See above.
Function Name: formatNumber()
Parameter 1: Variable Property Name (required)
Parameter 2: Number places after the ones place (required) – Typically number of places after the decimal.
Parameter 3: Delimiter character between the ones and the tenths place (required).
Parameter 4: Delimiter character between each 1000x magnitude (required).
Parameter 5: $_num – This lets the template service keep track of the iteration number.
Parameter 6: Variable Name (required).
Example Loan Payment Schedule:
<table><tbody>
<tr>
<th>Period</th>
<th>Payment Amount</th>
<th>Payment Date</th>
<th>Principal Remaining</th>
</tr>
<!–[[BEGIN scheduled-payments]]–>
<tr>
<td>[[period]]</td>
<td>$[[formatNumber('amount', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
<td>[[companyFormatDateTime('date', ", $_num, 'scheduled-payments')]]</td>
<td>$[[formatNumber('principal-balance', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
</tr>
<!–[[END]]–>
</tbody></table>
This example will iterate the scheduled payments on the loan from the loan transactions report, and will display a list of payment due dates and amounts. The example above would output something similar to the following formatted inside of a table using HTML:
Scheduled Payments:
Period Payment Amount Payment Date Principal Remaining
1 $439.58 10/01/2015 $4,602.09
2 $439.58 11/01/2015 $4,200.86
3 $439.58 12/01/2015 $3,796.29
4 $439.58 01/01/2016 $3,388.35
5 $439.58 02/01/2016 $2,977.01
6 $439.58 03/01/2016 $2,562.24
7 $439.58 04/01/2016 $2,144.01
8 $439.58 05/01/2016 $1,722.30
9 $439.58 06/01/2016 $1,297.07
10 $439.58 07/01/2016 $868.30
11 $439.58 08/01/2016 $435.96
12 $439.58 09/01/2016 $0.00
Note: When using loops inside of HTML tables, the [[BEGIN]] and [[END]] statements must be encapsulated in HTML comment tags. See above.
Manipulating arrays
When using variables, either in dynamic templates, receipts or emails there may be cases when you want to be more specific when referencing transactions. For example, if you send out a statement to your borrowers with all of their transactions, it may contain more information than you'd like and cause confusion for the borrower. Using array manipulation, you can now filter certain array variables to further customize your dynamic templates. This section will first explain the functions that are available and then provide an example of how to implement this in your tenant today.
Using manipulated variables
This feature is built to work with both indexed and associative arrays. Because the template engine is PHP-based, the type of arrays you use matter and it will be important to know the difference between the two types.
-
Indexed arrays: uses a numeric index to access different items within an array. By default, the first item will always have an index of “0”. For a simple example, we can use an array that has numbers as items:
my_array = [1, 2, 3, 4]
. If I wanted to reference the number "1”, I would use the index “0” to access it which would look something this this:my_array[0] => 1
. -
Associative arrays: uses defined keys rather than numbers to access the items. For example, the keys would be defined in the array:
my_array = ["one" => 1, “two” => 2, “three” =>, “four” => 4]
. Then, to access the items, you would use the key in quotation marks:my_array ["one"] => 1
.
When you're manipulating an array, be sure to pay attention to the type of array you're attempting to filter and choose the function that will work best for that array type.
Functions
This section will explain what functions are available, how each of them work, and what information is pulled when they are used. There are currently four functions available: filter array by, filter associative array by, and get associative array item by key.
Filter array by
This function allows you to manipulate an array by filtering which items should be included in the array and removing the rest. For example, you may want to pull transaction data but only include “swipe” transactions rather than swipes, payment, charges/fees, credits, and balance rollovers. To use the filterArrayBy
function to manipulate this array you will need to following arguments:
-
An indexed array to filter. This should be an array that already exists in LoanPro's context engine. In the example below, we'll use the
loc-transactions-array.current
array. -
The key in each element to filter by. This should be one of the available keys in the array. In the example below, we'll use
type
. -
The expected value to match. This will determine what specific transaction types should be included. In this example we'll filter for only
swipe
transactions. -
The name or alias of the resulting temporary array. With this filter, you're creating a custom, temporary array. Here, you will define the name of the array. For this example, we'll use
_loc_swipes
. In some cases, you may need to use this name to further filter an array.
When you've determined what each argument will be, you'll use them to write the function and use it in your variable. Using the defined examples above, the function would look like this:
<!-- [[filterArrayBy('loc-transactions-array.current', 'type', 'swipe', '_loc_swipes')]] -->
Once the function is written, it must be used as an embedded comment in the HTML block of your Dynamic Template. For more in-depth instructions on creating dynamic templates, see our Dynamic Templates article.
The “loc-transactions-array.current” is an indexed array (current) inside of an associative array (loc-transactions-array).
When used in a Dynamic Template, the function will pull the information and display in the form. But, to see a full breakdown of how this array pulls information with and without the filter, expand the fold below.
Example
Without the filter, a “loc-transactions-array” would pull something similar to this:
{
"loc-transactions-array": {
"current": [
{
"id": 4435,
"date": "2025-02-06",
"amount": 6.1399999999999997,
"status": "lineOfCredit.transactionStatus.active",
"memo": "NSF Fee",
"start-date": "2025-01-21",
"end-date": "2025-02-20",
"type": "fees"
},
{
"id": 49145,
"date": "2025-02-11",
"amount": 7.6200000000000001,
"memo": "Kroger #69364 Kenai, AK 99611",
"status": "lineOfCredit.transactionStatus.settled",
"merchant": "Kroger",
"bucket-label": "UAT API 257",
"start-date": "2025-01-21",
"end-date": "2025-02-20",
"type": "swipe"
}
]
}
}
With the “loc-swipes” filter, the payload would look like this:
{
"_loc_swipes": [
{
"id": 49145,
"date": "2025-02-11",
"amount": 7.6200000000000001,
"memo": "Kroger #69364 Kenai, AK 99611",
"status": "lineOfCredit.transactionStatus.settled",
"merchant": "Kroger",
"bucket-label": "UAT API 257",
"start-date": "2025-01-21",
"end-date": "2025-02-20",
"type": "swipe"
}
]
}
Filter associative array by
This functions works much like “filterArrayBy”, but it will skip to the level past the named key to apply the filter. For example, you might want to use a cards-array
, but only pull transactions by the primary customer. This function would pull the transaction made only by the primary customer and skip the transactions of the secondary customer. To use the filterAssocArrayBy
, following arguments are required:
-
An associative array to filter. This should be an array that already exists in LoanPro's context engine. In the example below, we'll use the
cards-array
. -
The key in each element to filter by. Defines what key to use when filtering this array. In this example, we'll use the
customer-role
key. -
The expected value to match. This will determine which customer transactions to pull. In this example, we want to pull transactions for the
Primary
customer. -
The name or alias of the resulting temporary array. With this filter, you're creating a custom, temporary array. Here, you will define the name of the array. For this example, we'll use
_primary_customer_cards
. In some cases, you may need to use this name to further filter an array.
When you've determined what each argument will be, you'll use them to write the function and use it in your variable. Using the defined examples above, the function would look like this:
<!-- [[filterArrayBy('cards-array', 'customer-role', 'Primary', '_primary_customer_cards')]] -->
When used in a Dynamic Template or other features, the function will pull the information and display in the form. But, to see a full breakdown of how this array pulls information with and without the filter, expand the fold below. To see how the array pulls information with and without the filter, expand the fold below.
Example payloads
Without the filter, the cards-array would pull something like this:
{
"cards-array": {
"id214": {
"id": 214,
"customer-id": 21323,
"customer-name": "Audrey Jones",
"customer-role": "Primary",
"cash-advance-bucket-id": 70,
"card-name": "optical port",
"created": "2025-02-11",
"last-updated": "2025-02-11",
"available-balance": 99999999645.059998,
"available-advance-balance": 99999999645.059998,
"spent-limit": 50000,
"spend-limit-interval": "monthly",
"card-currency": "USD",
"network": "visa",
"card-type": "physical",
"cash-advance-bucket-title": "UAT API 257",
"card-status": "active"
},
"id215": {
"id": 215,
"customer-id": 21316,
"customer-name": "Laura Bridgeman",
"customer-role": "Secondary",
"cash-advance-bucket-id": 70,
"card-name": "multi-byte alarm",
"created": "2025-02-11",
"last-updated": "2025-02-11",
"available-balance": 99999999645.059998,
"available-advance-balance": 99999999645.059998,
"spent-limit": 50000,
"spend-limit-interval": "monthly",
"card-currency": "USD",
"network": "visa",
"card-type": "physical",
"cash-advance-bucket-title": "UAT API 257",
"card-status": "active"
}
}
}
With the filter, only the following information is pulled:
{
"_primary_customer_cards": {
"id214": {
"id": 214,
"customer-id": 21323,
"customer-name": "Audrey Jones",
"customer-role": "Primary",
"cash-advance-bucket-id": 70,
"card-name": "optical port",
"created": "2025-02-11",
"last-updated": "2025-02-11",
"available-balance": 99999999645.059998,
"available-advance-balance": 99999999645.059998,
"spent-limit": 50000,
"spend-limit-interval": "monthly",
"card-currency": "USD",
"network": "visa",
"card-type": "physical",
"cash-advance-bucket-title": "UAT API 257",
"card-status": "active"
}
}
}
Get associative array item by key
This function can only be used in the scope of an existing loop. It will bring data from an associative array into the existing array so it can be included in the loop. For example, you could use this function to pull more information on a specific swipe. In the example outlined below, we'll use the filtered array _loc_swipes
that we created earlier in this section and link it to another array to pull more information on a specific swipe. When the array is associated, it will take the id from the _loc_swipes
array, associate it with the correct swipe in the _swipe_data
array, and then display more data on the swipe. To use this function, the following arguments are required:
-
An associative array to retrieve data from. This should be an array that already exists in LoanPro's context engine. In the example below, we'll use the
swipes-array
. -
The key from the indexed array's be matched to a named key in the associative array. In this example we'll use
id
. -
The name or alias of the resulting temporary array. With this filter, you're creating a custom, temporary property to be inserted into the looping array's element. Here, you will define the name of the property. For this example, we'll use
_swipe_data
.
When you've determined what each argument will be, you'll use them to write the function and use it in your variable. Using the defined examples above, the function would look like this:
<!-- [[begin _loc_swipes]] -->
<!-- [[getAssocArrayItemByKey('swipes-array', 'id', '_swipe_data')]] -->
When used in a Dynamic Template or other features, the function will pull the information and display in the form. But, to see a full breakdown of how this array pulls information with and without the filter, expand the fold below. To see how the array pulls information with and without the filter, expand the fold below.
Example
The swipes-array
will something like this:
{
"swipes-array": {
"id49145": {
"id": 49145,
"apply-date": "2025-02-113",
"settled-date": null,
"amount": 7.62000000000000016,
"memo": "Albertsons #66058 Arvada, CO 80007",
"status": "lineOfCredit.transactionStatus.settled",
"merchant": "Albertsons",
"merchant-logo-url": "https://content.mx.com/logos/merchants/MCH-d71a80e9-3bec-d67f-7fd9-f4d37e060aa0.png",
"merchant-logo-name": null,
"merchant-transaction-id": null,
"merchant-category-code": 583,
"merchant-categories": "Restaurant",
"merchant-info": "Albertsons #66058 Arvada, CO 80007",
"merchant-recurring": 0,
"billing-cycle": 2,
"merchant-address1": null,
"merchant-address2": null,
"merchant-city": null,
"merchant-state": "",
"merchant-country": null,
"merchant-zip": null,
"merchant-geo-lat": 0,
"merchant-geo-lon": 0,
"bucket-id": 88,
"bucket-title": "UAT API 339",
"card-id": 214
}
}
}
The manipulated array would pull something like this:
{
"id": 49145,
"date": "2025-02-11",
"amount": 7.6200000000000001,
"memo": "Albertsons #66058 Arvada, CO 80007",
"status": "lineOfCredit.transactionStatus.settled",
"merchant": "Albertsons",
"bucket-label": "UAT API 257",
"start-date": "2025-01-21",
"end-date": "2025-02-20",
"type": "swipe",
"_swipe_data": {
"id": 49145,
"apply-date": "2025-02-113",
"settled-date": null,
"amount": 7.62000000000000016,
"memo": "Albertsons #66058 Arvada, CO 80007",
"status": "lineOfCredit.transactionStatus.settled",
"merchant": "Albertsons",
"merchant-logo-url": "https://content.mx.com/logos/merchants/MCH-d71a80e9-3bec-d67f-7fd9-f4d37e060aa0.png",
"merchant-logo-name": null,
"merchant-transaction-id": null,
"merchant-category-code": 583,
"merchant-categories": "Restaurant",
"merchant-info": "Albertsons #66058 Arvada, CO 80007",
"merchant-recurring": 0,
"billing-cycle": 2,
"merchant-address1": null,
"merchant-address2": null,
"merchant-city": null,
"merchant-state": "",
"merchant-country": null,
"merchant-zip": null,
"merchant-geo-lat": 0,
"merchant-geo-lon": 0,
"bucket-id": 88,
"bucket-title": "UAT API 339",
"card-id": 214
}
}
Sort array by key
This function is used to sort items within a Dynamic Template. For example, say you'd like to list all of the payments by date. If you're using a normal array, this would not include backdated or reversed payments in the correct order because of how to array pulls the items. To get the payments in the right order, you can use this function to sort by date. The following arguments are required:
-
An array to sort. This should be an array that already exists in LoanPro's context engine. In the example below, we'll use the
payments
array. -
The key by which to sort. Here, you will define which key should be used to sort the items in the array. In the example below, we'll use
payment-date
. - The sort order. Use 'asc' for ascending or 'desc' for descending. In the example below, we'll use ‘desc’.
-
The name or alias of the resulting temporary array. With this filter, you're creating a custom, temporary array. Here, you will define the name of the array. For this example, we'll use
_sorted_payments
. In some cases, you may need to use this name to further filter an array.
When you've determined what each argument will be, you'll use them to write the function and use it in your variable. Using the defined examples above, the function would look like this:
<!-- [[sortArrayByKey(payments, 'payment-date', 'desc', '_sorted_payments')]] -->
<!-- [[begin _sorted_payments]] -->
When used in a Dynamic Template or other features, the function will pull the information and display in the form. But, to see a full breakdown of how this array pulls information with and without the filter, expand the fold below. To see how the array pulls information with and without the filter, expand the fold below.
Example
Without the filter, the payments
array would pull something like this:
{
"payments": {
"1905": {
"before-principal-balance": 9810.6100000000006,
"before-payoff": 9877.8899999999994,
"before-next-due-date": "2024-10-08",
"before-next-due-amount": 158.81999999999999,
"before-amount-past-due": 635.27999999999997,
"before-days-past-due": 103,
"after-principal-balance": 9810.6100000000006,
"after-payoff": 9865.8899999999994,
"after-next-due-date": "2024-10-08",
"after-next-due-amount": 158.81999999999999,
"after-amount-past-due": 623.27999999999997,
"after-days-past-due": 103,
"payment-amount": 12,
"payment-date": "2024-09-19",
"payment-info": "09/19/2024 Bank Account",
"display-id": "3837",
"system-id": 1905,
"interest": 12,
"principal": 0,
"discount": 0,
"escrow": 0,
"fees": 0,
"full-payment-amount": 12,
"payment-fee-amount": 0,
"payment-method": "Bank Account",
"source-company": "",
"loan-status": "Open",
"loan-substatus": "Rescind Request",
"associated-portfolios": {
"1": "Portfolio A"
},
"associated-subportfolios": {
"1": "Sub A-A"
}
},
"1920": {
"before-principal-balance": 9810.6100000000006,
"before-payoff": 9945.3899999999994,
"before-next-due-date": "2025-03-08",
"before-next-due-amount": 158.81999999999999,
"before-amount-past-due": 1417.3800000000001,
"before-days-past-due": 262,
"after-principal-balance": 9810.6100000000006,
"after-payoff": 9893.3899999999994,
"after-next-due-date": "2025-03-08",
"after-next-due-amount": 158.81999999999999,
"after-amount-past-due": 1365.3800000000001,
"after-days-past-due": 262,
"payment-amount": 52,
"payment-date": "2025-02-24",
"payment-info": "02/24/2025 Cash",
"display-id": "3838",
"system-id": 1920,
"interest": 49.609999999999999,
"principal": 2.3900000000000001,
"discount": 0,
"escrow": 0,
"fees": 0,
"full-payment-amount": 52,
"payment-fee-amount": 0,
"payment-method": "Cash",
"source-company": "",
"loan-status": "Open",
"loan-substatus": "Rescind Request",
"associated-portfolios": {
"1": "Portfolio A"
},
"associated-subportfolios": {
"1": "Sub A-A"
}
}
}
}
With the sort function, the payments are ordered like this:
{
"payments": {
"1920": {
"before-principal-balance": 9810.6100000000006,
"before-payoff": 9945.3899999999994,
"before-next-due-date": "2025-03-08",
"before-next-due-amount": 158.81999999999999,
"before-amount-past-due": 1417.3800000000001,
"before-days-past-due": 262,
"after-principal-balance": 9810.6100000000006,
"after-payoff": 9893.3899999999994,
"after-next-due-date": "2025-03-08",
"after-next-due-amount": 158.81999999999999,
"after-amount-past-due": 1365.3800000000001,
"after-days-past-due": 262,
"payment-amount": 52,
"payment-date": "2025-02-24",
"payment-info": "02/24/2025 Cash",
"display-id": "3838",
"system-id": 1920,
"interest": 49.609999999999999,
"principal": 2.3900000000000001,
"discount": 0,
"escrow": 0,
"fees": 0,
"full-payment-amount": 52,
"payment-fee-amount": 0,
"payment-method": "Cash",
"source-company": "",
"loan-status": "Open",
"loan-substatus": "Rescind Request",
"associated-portfolios": {
"1": "Portfolio A"
},
"associated-subportfolios": {
"1": "Sub A-A"
}
},
"1905": {
"before-principal-balance": 9810.6100000000006,
"before-payoff": 9877.8899999999994,
"before-next-due-date": "2024-10-08",
"before-next-due-amount": 158.81999999999999,
"before-amount-past-due": 635.27999999999997,
"before-days-past-due": 103,
"after-principal-balance": 9810.6100000000006,
"after-payoff": 9865.8899999999994,
"after-next-due-date": "2024-10-08",
"after-next-due-amount": 158.81999999999999,
"after-amount-past-due": 623.27999999999997,
"after-days-past-due": 103,
"payment-amount": 12,
"payment-date": "2024-09-19",
"payment-info": "09/19/2024 Bank Account",
"display-id": "3837",
"system-id": 1905,
"interest": 12,
"principal": 0,
"discount": 0,
"escrow": 0,
"fees": 0,
"full-payment-amount": 12,
"payment-fee-amount": 0,
"payment-method": "Bank Account",
"source-company": "",
"loan-status": "Open",
"loan-substatus": "Rescind Request",
"associated-portfolios": {
"1": "Portfolio A"
},
"associated-subportfolios": {
"1": "Sub A-A"
}
}
}
}
Generated template
You can apply these functions to fit the needs of your Dynamic Template. Below, we've created an example using some of the functions covered above.
If you'd like to generate your own form with the same format as the example, you can use the HTML code within the drop down field below.
HTML code
<!-- ALL ACTIVITY-->
<div style="background-color: #cbd4f3; color: #5546c1; padding: 10px; border-radius: 7px 7px 0px 0px;"><strong><span style="font-family: arial, helvetica, sans-serif;">All Transactions</span></strong></div>
<table style="width: 100.005%; height: 10px;">
<tbody>
<tr style="height: 10px; border: 1px solid rgb(203, 212, 243); background-color: rgb(0, 0, 0);">
<td style="width: 10.8743%; text-align: left; color: rgb(39, 49, 63); padding: 5px; font-size: 11pt; height: 10px; background-color: #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle;"><span style="font-size: 10pt; color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Date</strong></span></td>
<td style="width: 32.5647%; color: rgb(39, 49, 63); padding: 5px; font-size: 11pt; height: 10px; text-align: left; background-color: #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle;"><span style="font-size: 10pt; color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Type</strong></span></td>
<td style="width: 28.7267%; color: rgb(39, 49, 63); padding: 5px; font-size: 11pt; height: 10px; text-align: left; background-color: #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle;"><span style="font-size: 10pt; color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Description</strong></span></td>
<td style="width: 16.515%; color: rgb(39, 49, 63); padding: 5px; font-size: 11pt; height: 10px; #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle; text-align: left;"><span style="font-size: 10pt; color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Status</strong></span></td>
<td style="width: 11.165%; text-align: right; color: rgb(0, 0, 0); padding: 5px; font-size: 10pt; height: 10px; font-family: arial, helvetica, sans-serif; background-color: #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle;"><span style="color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Amount<!--[[BEGIN loc-transactions-array.current]]--></strong></span></td>
</tr>
<tr style="height: 10px; border-bottom: 2px solid rgb(203, 212, 243);">
<td style="width: 10.8743%; text-align: left; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; height: 10px;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">[[formatDateTime($date, 'm/d/Y')]]</span></td>
<td style="width: 32.5647%; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; height: 10px; text-align: left;"><span style="font-size: 8pt; font-family: arial, helvetica, sans-serif;">[[IF $type == "swipe"]][[$bucket-label]][[ELSE]][[END]] [[ucwords('[[strtolower($type)]]')]]</span></td>
<td style="width: 28.7267%; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; text-align: left; height: 10px;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">[[IF $merchant]][[$merchant]][[ELSEIF $memo]][[$memo]][[ELSEIF $type== "credit"]][[$info]][[ELSEIF $type == "payment"]]{{IF $status == "reversed"}}Reversed Payment{{ELSEIF $status == "active" || $status == "settled"}}Successful Payment{{ELSE}}{{END}}[[ELSE]][[END]] </span></td>
<td style="width: 16.515%; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; height: 21.6562px; text-align: left;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">{{IF $status == "active" || $status == "lineOfCredit.transactionStatus.active" || $status == "settled" || $status == "lineOfCredit.transactionStatus.settled"}}Settled{{ELSEIF $status == "pending" || $status == "lineOfCredit.transactionStatus.pending"}}Pending{{ELSE}}[[$status]]{{END}}</span></td>
<td style="width: 11.165%; text-align: right; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; height: 10px;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">[[IF $type == "payment"]]- $[[formatNumber($amount, '2', '.', ',')]][[ELSEIF $type == "credit"]]- $[[formatNumber($amount, '2', '.', ',')]][[ELSE]]$[[formatNumber($amount, '2', '.', ',')]][[END]]</span></td>
</tr>
<!--[[END]]--></tbody>
</table>
<p></p>
<!-- PRIMARY CUSTOMER'S SWIPES-->
<div style="background-color: #cbd4f3; color: #5546c1; padding: 10px; border-radius: 7px 7px 0px 0px;"><strong><span style="font-family: arial, helvetica, sans-serif;">[[v('customer.primary.full-name')]]</span></strong></div>
<table style="width: 100%; height: 27px;">
<tbody>
<tr style="height: 17px; border: 1px solid rgb(203, 212, 243); background-color: rgb(0, 0, 0);">
<td style="width: 16.116%; text-align: left; color: rgb(39, 49, 63); padding: 5px; font-size: 11pt; height: 17px; background-color: #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle;"><span style="font-size: 10pt; color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Date</strong></span></td>
<td style="width: 42.574%; color: rgb(39, 49, 63); padding: 5px; font-size: 11pt; height: 17px; text-align: left; background-color: #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle;"><span style="font-size: 10pt; color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Description</strong></span></td>
<td style="width: 24.4912%; color: rgb(39, 49, 63); padding: 5px; font-size: 11pt; height: 17px; background-color: #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle; text-align: left;"><span style="font-size: 10pt; color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Location</strong></span></td>
<td style="width: 16.5601%; text-align: right; color: rgb(0, 0, 0); padding: 5px; font-size: 10pt; height: 17px; font-family: arial, helvetica, sans-serif; background-color: #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle;"><span style="color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Amount</strong></span></td>
</tr>
<!-- [[filterArrayBy(loc-transactions-array.current, 'type', 'swipe', '_loc_swipes')]] -->
<!-- [[filterAssocArrayBy(cards-array, 'customer-role', 'loan.customerRole.primary', '_primary_card_array')]] -->
<!-- [[BEGIN _loc_swipes]] -->
<!-- [[getAssocArrayItemByKey(swipes-array, id, '_tmp_swipe')]] -->
<!-- [[getAssocArrayItemByKey(_primary_card_array, _tmp_swipe.card-id, '_tmp_card')]] -->
<!-- [[UNLESS _tmp_card]] -->
<!-- [[ELSE]] -->
<tr style="height: 10px; border-bottom: 2px solid rgb(203, 212, 243);">
<td style="width: 16.116%; text-align: left; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; height: 10px;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">[[formatDateTime($date, 'm/d/Y')]]</span></td>
<td style="width: 42.574%; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; text-align: left; height: 10px;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">[[memo]]</span></td>
<td style="width: 24.4912%; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; height: 10px; text-align: left;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">[[_tmp_swipe.merchant-city]], [[_tmp_swipe.merchant-state]]</span></td>
<td style="width: 16.5601%; text-align: right; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; height: 10px;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">$[[formatNumber($amount, '2', '.', ',')]]</span></td>
</tr>
<!-- [[END ] --> <!-- [[END]]--></tbody>
</table>
<!-- SECONDARY CUSTOMER'S SWIPES-->
<p></p>
<!--[[IF $customer.secondary]]-->
<div style="background-color: #cbd4f3; color: #5546c1; padding: 10px; border-radius: 7px 7px 0px 0px;"><strong><span style="font-family: arial, helvetica, sans-serif;">[[v('customer.secondary.full-name')]]</span></strong></div>
<table style="width: 100%; height: 27px;">
<tbody>
<tr style="height: 17px; border: 1px solid rgb(203, 212, 243); background-color: rgb(0, 0, 0);">
<td style="width: 16.116%; text-align: left; color: rgb(39, 49, 63); padding: 5px; font-size: 11pt; height: 17px; #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle;"><span style="font-size: 10pt; color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Date</strong></span></td>
<td style="width: 42.574%; color: rgb(39, 49, 63); padding: 5px; font-size: 11pt; height: 17px; text-align: left; background-color: #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle;"><span style="font-size: 10pt; color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Description</strong></span></td>
<td style="width: 24.4912%; color: rgb(39, 49, 63); padding: 5px; font-size: 11pt; height: 17px; #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle; text-align: left;"><span style="font-size: 10pt; color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Location</strong></span></td>
<td style="width: 16.5601%; text-align: right; color: rgb(0, 0, 0); padding: 5px; font-size: 10pt; height: 17px; font-family: arial, helvetica, sans-serif; background-color: #000000; border: 1px solid rgb(0, 0, 0); vertical-align: middle;"><span style="color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif;"><strong>Amount</strong></span></td>
</tr>
<!-- [[filterArrayBy(loc-transactions-array.current, 'type', 'swipe', '_loc_swipes')]] -->
<!-- [[filterAssocArrayBy(cards-array, 'customer-role', 'loan.customerRole.secondary', '_secondary_card_array')]] -->
<!-- [[BEGIN _loc_swipes]] -->
<!-- [[getAssocArrayItemByKey(swipes-array, id, '_tmp_swipe')]] -->
<!-- [[getAssocArrayItemByKey(_secondary_card_array, _tmp_swipe.card-id, '_tmp_card')]] -->
<!-- [[UNLESS _tmp_card]] -->
<!-- [[ELSE]] -->
<tr style="height: 10px; border-bottom: 2px solid rgb(203, 212, 243);">
<td style="width: 16.116%; text-align: left; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; height: 10px;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">[[formatDateTime($date, 'm/d/Y')]]</span></td>
<td style="width: 42.574%; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; text-align: left; height: 10px;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">[[memo]]</span></td>
<td style="width: 24.4912%; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; height: 10px; text-align: left;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">[[_tmp_swipe.merchant-city]], [[_tmp_swipe.merchant-state]]</span></td>
<td style="width: 16.5601%; text-align: right; color: rgb(39, 49, 63); padding: 3px; font-size: 11pt; height: 10px;"><span style="font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); font-size: 8pt;">$[[formatNumber($amount, '2', '.', ',')]]</span></td>
</tr>
<!-- [[END]] --> <!-- [[END]]--></tbody>
</table>
<p><br><br></p>
<!--[[ELSE]][[END]]-->
For step-by-step instructions on how to create a Dynamic Template using HTML, see our Dynamic Templates article.
Was this article helpful?
Unclassified Public Data