Skip to content

Commit 0ffa141

Browse files
Florian KroenertFlorian Kroenert
authored andcommitted
Added docs
1 parent 029ebc5 commit 0ffa141

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ A domain specific language for Dynamics CRM allowing for easy text template proc
5757
- [DateToString](#datetostring)
5858
- [ConvertDateTime](#convertdatetime)
5959
- [Format](#format)
60+
- [FormatString](#formatstring)
6061
- [RetrieveAudit](#retrieveaudit)
6162
- [Snippet](#snippet)
6263
- [Example - Refer to Snippet using unique name](#example---refer-to-snippet-using-unique-name)
@@ -669,6 +670,27 @@ Format( Value("index"), { format: "{0:00000}" } ) // Will print 00001 for index
669670

670671
Refer to the .NET style for date formatting.
671672

673+
### FormatString
674+
**Available since: v3.9.16**
675+
676+
Used for inserting values into a format string.
677+
678+
Values can be accessed via $index, where the index starts at 0
679+
(e.g. $0, $1, $2, …).
680+
681+
Only numeric placeholders are replaced. Any $ that is not followed by a number is treated as literal text.
682+
683+
If the format string needs to contain a $ character followed by a number that must not be replaced, escape it with a backslash: \$.
684+
685+
Replacement is applied only to the format string.
686+
Inserted values are not processed again.
687+
688+
Example:
689+
``` JavaScript
690+
FormatString( 'Hey $0, you did not buy anything, so your invoice is \$0!', 'Bilbo' ) // Will print 'Hey Bilbo, you did not buy anything, so your invoice is $0!
691+
```
692+
693+
672694
### RetrieveAudit
673695
**Available since: v3.8.1**
674696

src/test/Xrm.Oss.XTL.Interpreter.Tests/FormattingTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ public void It_Should_Escape_Dollars_In_Format_String()
114114
var service = context.GetFakedOrganizationService();
115115
var tracing = context.GetFakeTracingService();
116116

117-
var formula = @"FormatString('Hey there $0, you owe me 5\$', 'Bilbo Baggins')";
118-
Assert.That(() => new XTLInterpreter(formula, null, null, service, tracing).Produce(), Is.EqualTo("Hey there Bilbo Baggins, you owe me 5$"));
117+
var formula = @"FormatString('Hey there $0, your invoice is \$5', 'Bilbo Baggins')";
118+
Assert.That(() => new XTLInterpreter(formula, null, null, service, tracing).Produce(), Is.EqualTo("Hey there Bilbo Baggins, your invoice is $5"));
119119
}
120120

121121
[Test]

0 commit comments

Comments
 (0)