About this article
This article explains what the DataSources[] function is and provide examples of how it can be used with the binding syntax in smart templates.
Prerequisites
|
What is the DataSources[] function?
DataSources[] is a function that returns the values from a specific data source row.
DataSources[] logic
Syntax | {{DataSources.DataSourceName[NameValueToLookUp].DataSourceColumnName}} |
|
DataSources[] function examples
In the examples below these data sources are used. The column Country of the Offices data source is a reference to the column Name of the Countries data source:
|
Example 1
Using the DataSources[] function with plain text to retrieve the postal code of the Eindhoven office.
|
Binding | {{DataSources.Offices["Office Eindhoven"].PostalCode}} |
Input | n/a |
Output | 5611 ZB |
Example 2
Using the DataSources[] function with the "OfficeName" flexible dropdown question originating from the response form to retrieve the correct postal code for the office.
Binding | {{DataSources.Offices[Form.OfficeName].PostalCode}} | |
Input | Office Copenhagen | Office Eindhoven |
Output | 1403 | 5611 ZB |
Example 3
Using the DataSources[] function with the "OfficeName.Name" dropdown question originating from the response form to retrieve the correct postal code for the office.
|
Binding | {{DataSources.Offices[Form.OfficeName.Name].PostalCode}} | |
Input | Office New York | Office Copenhagen |
Output | 10007 | 1403 |
Example 4
Using the DataSources[] function with the "OfficeName" flexible dropdown question originating from the response form to retrieve the country of the office.
|
Binding | {{DataSources.Offices[Form.OfficeName].Country.Name}} | |
Input | Office Berlin | Office Sydney |
Output | Germany | Australia |
Example 5
Using the DataSources[] function with the "OfficeName" flexible dropdown question originating from the response form to retrieve multiple fields from the data source row.
Binding | Location Templafy {{DataSources.Offices[Form.OfficeName].City}}: {{DataSources.Offices[Form.OfficeName].Address}}, {{DataSources.Offices[Form.OfficeName].PostalCode}}, {{DataSources.Offices[Form.OfficeName].City}}, {{DataSources.Offices[Form.OfficeName].Country.Name}} | |
Input | Office Sydney | Office Berlin |
Output | Location Templafy Sydney: 151 Clarence Street, NSW 2000, Sydney, Australia | Location Templafy Berlin: Lützowstr. 100, 10785, Berlin, Germany |
|
Example 6
Using the DataSources[] function to insert an image stored in a data source.
Binding | {{DataSources.DataSourceName["ImageName"].DataSourceColumnName}} |
Example 7
If you want your email signature or Word document to contain a 'tip of the day' (showing a different tip every day) then create a table containing all 366 possible dates (format 'month/day') and texts like this:
Insert a tip based on today's date:
Binding | {{DataSources.TipOfTheDay[FormatDateTime(Now(),"MM-dd","en-US")].Tip}} | |
Input | Today's date = "January 2" | Today's date = "December 31" |
Output | "To increase the font size, highlight the text and then press Ctrl+]." | "To insert a non-breaking hyphen press Ctrl+Shift+_." |
Insert a tip based on the value of the "Date" question originating from the response form:
Binding | {{DataSources.TipOfTheDay[Form.Date,"MM-dd","en-US")].Tip}} | |
Input | Date = "January 2" | Date = "December 31" |
Output | "To increase the font size, highlight the text and then press Ctrl+]." | "To insert a non-breaking hyphen press Ctrl+Shift+_." |
Related articles
Comments
0 comments
Article is closed for comments.