Articles in this section

How to get the value from a specific column and row within a Data Source using DataSources[]

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:

 

 

datasources_reference.png

 

Example 1

Using the DataSources[] function with plain text to retrieve the postal code of the Eindhoven office. 

 
  • Plain text must be enclosed in quotation marks.

 

Binding {{DataSources.Offices["Office Eindhoven"].PostalCode}}
Input n/a
Output 5611 ZB

 

 
  • The DataSources[] function is case sensitive, so for example the binding {{DataSources.Offices["Office Eindhoven"].Postalcode}} will not work.
  • The binding {{DataSources.Offices["Office eindhoven"].PostalCode}} will work, but as 'Office eindhoven' does not exist ('eindhoven' is not the same as 'Eindhoven'), the output will be empty.

 

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. 

 
  • Please note, in the binding you need to use {{Form.OfficeName.Name}}, because it's a dropdown field.

 

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. 

 
  • Please note that the Country is stored in the Name column of the Countries data source and is used as a reference in the Offices data source.

 

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

 

 
  • Please note, for all examples explained, if no value is resolved then "" is returned.

 

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:

tipoftheday.png

 

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

 

 

hostsystem header headers help text tech_role
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.