About this article
StringJoin() is a function that joins multiple pieces of text together with a separator in between.
Pre-requisites
|
Syntax
Syntax | {{StringJoin(Separator, Value1, Value2, Value3...)}} |
Input | separator and text |
Output | joined text with separator in between |
Example 1
Using the StringJoin() function to join two pieces of text with a dash in between.
Binding | {{StringJoin("-", "text1", "text2")}} |
Output | "text1-text2" |
Example 2
Using the StringJoin() function to join 3 pieces of text with a slash in between.
Binding | {{StringJoin("/", "text1", "text2", "text3")}} |
Output | "text1/text2/text3" |
Example 3
Insert an address and allow the user to define their own separator in a form.
Binding | {{StringJoin(Form.Separator, Form.Street, Form.City, Form.Zipcode, Form.Country)}} |
Input | Form.Separator = "-" |
Output | "123 Washington Rd.-Lake Forest-60045-USA" |
Example 4
Insert an address with the Form.Zipcode being empty or containing a value.
Binding | {{StringJoin(" | ", Form.Street, Form.City, Form.Zipcode, Form.Country)}} | |
Input | Form.Zipcode = "" | Form.Zipcode = "60045" |
Output | "123 Washington Rd. | Lake Forest | USA" | "123 Washington Rd. | Lake Forest | 60045 | USA" |
Example 5
Using the IfElse() function to include a StringJoin() footer address if a checkbox is checked. Otherwise, add a blank content control.
Binding | {{IfElse(Form.IncludeAddress, StringJoin(" | ", Form.Street, Form.City, Form.Zipcode, Form.Country), "")}} |
Input | Checkbox is checked |
Condition | True |
Output | "123 Washington Rd. | Lake Forest | 60045 | USA" |
Example 6
Using the IfElse() function in combination with StringJoin() to hide text (using a Group element) if both questions 1 and 2 are empty.
Binding | {{IfElse(Equals(StringJoin("", Form.Question1, Form.Question2), ""), VisibilityType.Hidden, VisibilityType.Visible)}} |
Input | Form.Question1 = "" and Form.Question2 = "" |
Output | Hidden text |
Example 7
Using a nested StringJoin() function in combination with IfElse() to show plain text ("E:", "P:" and "W:") combined with the value of the user profile field.
Binding | {{StringJoin(" | ", StringJoin(" ", IfElse(Equals(UserProfile.Email, ""), "", "E:"), UserProfile.Email), StringJoin(" ", IfElse(Equals(UserProfile.Phone, ""), "", "P:"), UserProfile.Phone), StringJoin(" ", IfElse(Equals(UserProfile.Website, ""), "", "W:"), UserProfile.Website))}} | |
Input |
UserProfile.Email = "info@test.com", |
UserProfile.Email = "info@test.com", |
Output | E: info@test.com | W: www.test.com |
E: info@test.com | P: +31401234567 | W: www.test.com |
Example 8
Using a nested StringJoin() function in combination with IfElse() to show plain text depending on the document language, combined with the value of the user profile field.
This is the same binding used in example 7, but with the plain text ("E:", "P:" and "W:") replaced by the Translate() function. The Translations data source looks like this:
Binding | {{StringJoin(" | ", StringJoin(" ", IfElse(Equals(UserProfile.Email, ""), "", Translate("EmailShort", DocumentLanguage)), UserProfile.Email), StringJoin(" ", IfElse(Equals(UserProfile.Phone, ""), "", Translate("PhoneShort", DocumentLanguage)), UserProfile.Phone), StringJoin(" ", IfElse(Equals(UserProfile.Website, ""), "", Translate("WebsiteShort", DocumentLanguage)), UserProfile.Website))}} | |
Input |
UserProfile.Email = "info@test.com", DocumentLanguage = "en-US" |
UserProfile.Email = "info@test.com", DocumentLanguage = "nl-NL" |
Output | E: info@test.com | P: +31401234567 | W: www.test.com |
E: info@test.com | T: +31401234567 | W: www.test.com |
Example 9
If a binding looks like this {{StringJoin(" ", UserProfile.Email, UserProfile.Phone, UserProfile.Website)}}
, then in the document the result will show all values on one line. To show each value on a separate line, you can use the escape sequence \n
for a new line. However you cannot type \n
in the Binding field in Dynamics Designer directly. Instead, follow the steps below:
Word:
- In the Binding field create this binding:
{{StringJoin(" ", UserProfile.Email, UserProfile.Phone, UserProfile.Website)}}
. - Open the properties of the content control on the Developer tab.
- In the Tag field, change the part
{{StringJoin(\" \",
to{{StringJoin(\"\n\",
. - The result looks like this:
- Note that the Binding field in Dynamics Designer will not show the
\n
in the binding.
- Note that the Binding field in Dynamics Designer will not show the
PowerPoint:
- In the Master View select the Shape.
- In the Binding field create this binding:
{{StringJoin(" ", UserProfile.Email, UserProfile.Phone, UserProfile.Website)}}
. - Right-click the Shape and select
Edit Alt Text
. - In the Alt Text task pane, change the part
{{StringJoin(\" \",
to{{StringJoin(\"\n\",
. - The result looks like this:
- Note that the Binding field in Dynamics Designer will not show the
\n
in the binding.
- Note that the Binding field in Dynamics Designer will not show the
Binding (Tag in Word / Alt Text in PowerPoint) |
{"templafy":{"type":"text","binding":"{{StringJoin(\"\n\", UserProfile.Email, UserProfile.Phone, UserProfile.Website)}}"}} | |
Input |
UserProfile.Email = "info@test.com", |
UserProfile.Email = "info@test.com", |
Output | E: info@test.com W: www.test.com |
E: info@test.com |
Related articles
Comments
0 comments
Article is closed for comments.