When it comes to pulling data from a client database, you probably want your users to type in a number, press TAB and populate the interview immediately with data.
Type in your number, and press TAB
Example code:
The code for that looks like this:
«LinkToDataSource(AccountNumber,Clients,RefreshNoSave,id=<AccountNumber>)»
where AccountNumber is the field into which they enter the number, and Clients is the name of the configured data source.
Configuration:
Note that in the Configured data source, AccountNumber is the IdColumn which corresponds to the command above.
Summary of all parameters in the LinkToDataSource command:
AccountNumber | The data element from which the link should be executed. Note that this is a Link on exit. We have a separate command called LinkToDataSourceOnEnter |
Clients | The configured data source name |
Refresh/Save | Refresh and save options as described below |
Id or Range | Id will return 1 row, range will return a filtered collection of rows |
Condition | Optional. Use this to make the Link conditional. |
Save sub-option condition | Optional. Used in conjunction with the Save parameter. |
The Refresh and Save options
When running templates within the MS Word environment, the user has the option to run a template and then select ‘Use Other Data’ – which means use the Data Set saved from running this or another template on a previous occasion. This is a very useful feature, but has complications relating to data from Data Sources (and File Data).
The question arises about whether or not the data elements saved on the previous occasion should be used exactly as they were when the previous template was run. This is on the face of it what we would like. But, suppose some data elements were originally included from a data source, for example an Excel spreadsheet or a database, and the data elements in the data source have subsequently changed, should the new, changed data be used, or the data as saved when the last template was run?
In general, there is no hard and fast answer to this question, but in particular circumstances, the expectation would be that when data in a data source changes, it should affect not only new templates which reference that data source, but also templates using older data.
For this reason the IncludeDataSourceData
, ChooseFromDataSource
, IncludeFileData
and ChooseFromFile
commands all have a ‘refresh’ option. This indicates that when the user selects ‘Use Older Data’, then the data elements from the relevant data source must be refreshed from the data source and not copied directly from the originally saved data set.
Examples of usage are:
«IncludeDataSourceData(Clients,Refresh)»
«ChooseFromDataSource(Directors,Select the Director,Refresh)»
Related to this is the ‘Save’ option, which governs what happens when the user changes a value which originated from a data source. The template author can decide whether those changed items should be changed in the data source or not, or whether the user should be prompted to confirm that the data source should be changed.
The ‘Save’ option is connected to the ‘Refresh’ option in that if ‘Refresh’ is not chosen, then ‘Save’ cannot be chosen.
The full set of refresh and save options are, then:
– Refresh
– RefreshNoSave (which is the same as Refresh)
– RefreshOptionalSave: The user is prompted to save any changes.
– RefreshSave: Changes made by the user are saved without prompting the user.
The default for IncludeDataSourceData
and ChooseFromDataSource
is ‘Refresh’. The default for IncludeFileData
and ChooseFromFile
is also ‘Refresh’.