You're already familiar with user business rules and for many of you they've played a crucial role in your business processes. Starting with version 24, these rules now feature even more power and user-friendliness, enhancing your overall experience.
In this version, a new parameter type for user business rules, called Interpolate, was added. It is an alternative and much enhanced version of the so far used FormattedString parameter type. The Interpolate operator works with the ERP.net string interpolation functionality. String interpolation is a process in which an input string is broken into (interpolation) expressions. ERP.net tries to evaluate each interpolation expression and replace it with its string representation. It is available for each object.
Note that FormattedString will gradually be retired. Use Interpolate in new developments!
Using FormattedString, this text:
Your web store has a new order!\r\n
{SUMMARY\} \n
Number: {DocumentNo}\n
Order date: {DocumentDate:dd-MM-yyyy}\n
Shipping address:
{ShipToPartyContactMechanism.ContactMechanism.Name}\n
Order total: {#CalculatedAttributeTotalSalesOrderAmount:C}
gets returned as:
Your web store has a new order!
{SUMMARY}
order number: 00329
order date: 10-05-2023
shipping address: 21 Lombard St
delivery date: 12-05-2023
order total: $14.82
It has been working well for quite some time already and will continue working. However, it will not help you if you want to include the current date or user.
This is where Interpolate is coming to the rescue. With its help, a text like this:
Hello, {$user.Name}\r\n
Today is {$date}.\r\n
Your web store has a new order!\r\n
{{SUMMARY}}\r\n
Number: {DocumentNo}\r\n
From: {Customer.Party.PartyName}\r\n
Order date: {DocumentDate:dd-MM-yyyy}\r\n
Shipping address:{ShipToPartyContactMechanism.ContactMechanism.Name}\r\n
Order total: {#CalculatedAttributeTotalSalesOrderAmount:C}
gets translated to:
Hello, Jeremy Smith
Today is 2023-05-10.
Your web store has a new order!
{SUMMARY}
Number: 00329
From: Jane Doe
Order date: 10-05-2023
Shipping address: 21 Lombard St
Order total: $14.82
Take a note of the difference with the usage of the name of the currently logged in user and the current date, which are system variables. This is what makes the Interpolate parameter type much stronger when compared to the FormattedString one. It is yet another way to take advantage of string interpolation in ERP.net.
Check out our documentation to find additional information on the subject!
0 Comments