Variables Page
DataSync's Variables page is the user hub for variable management. You can add new variables as well as edit and delete existing variables from the Variables page.
To navigate to the Variables page, simply click on the Variables pane in the lower left-hand corner of the main DataSync navigation menu (shown below).
You can also navigate to the Variables page from anywhere in the DataSync interface by clicking the Variables icon in the left-hand side menu (see below).
Variable Applications
Variables allow you to pair a chosen name with a specified value. You can then recall the value of your variables in your data statements as many times as you need using the name you assigned to it.
Say you have a variable named @City with the value of Toronto. Now, rather than writing Toronto numerous times throughout your SQL statement, you can replace it with the @City variable. That way, if you ever decide to change Toronto (e.g., to Toronto, ON), you would simply change the value of @City, and it would instantly update every occurrence of the variable within your statement.
Some common variable applications in DataSync include:
- Creating customized filters and queries
- Purging tables (migration extractions only)
- Calculating data within a field
To formulate variables in DataSync, you must type an @ symbol followed by the variable's name as shown in the example below:
The main Variables page (shown below) lists all variables that are currently applied to any of your extractions at the Fields level.
For more information on actions that can be performed on the Variables page such as adding, editing or deleting variables, see Managing Variables.
Inserting RSD Parameters into an API Profile
Overview
Inserting RSD parameters into an API profile allows you to create generic RSDs, which can then be distributed to clients. This saves time by avoiding the need to create multiple RSDs, since all the parameters can simply be adjusted in the same RSD. The user can then use global variables or hard-coded values to adjust the parameters.
These parameters can have default values in the RSD files. If they don’t, errors will be displayed in DataSync requesting that you enter these value in the filter column of the extraction. The person creating the RSD defines which parameters have or do not have a default value.
Be careful when pre-populating an RSD with parameters and sending it. If the recipient is not using certain parameters and does not change their default values, they may accidentally point to another client’s information.
Implementation
First, you will need to have your RSD file correctly set up, then set the parameters up in the DataSync user interface. Below is an example of what a completed RSD file looks like with parameters:
<api:script xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:api="http://apiscript.com/ns?v1" >
<api:info title="CompanyStatus" desc="Returns the status of a company specified by its CompanyId." >
<attr name="CompanyId" xs:type="string" readonly="true" other:pseudocolumn="true" />
<attr name="Id" xs:type="string" readonly="true" other:xPath="id" key="true" />
<attr name="Title" xs:type="string" readonly="true" other:xPath="title" />
<attr name="Column1" xs:type="string" readonly="true" other:xPath="column1" />
<attr name="Column2" xs:type="string" readonly="true" other:xPath="column2" />
</api:info>
<!-- Setting global parameters -->
<api:set attr="ContentType" value="application/json" />
<api:validate attr="_input.CompanyId" desc="You must specify a CompanyId." />
<!-- Set authorization parameters -->
<!-- Using OAuth -->
<api:set attr="OAuthVersion" value="2.0" />
<api:validate attr="_connection.OAuthClientId" desc="OAuthClientId connection property should be specified for OAuth Authentication" />
<api:validate attr="_connection.OAuthClientSecret" desc="OAuthClientSecret connection property should be specified for OAuth Authentication" />
<api:validate attr="_connection.CallbackUrl" desc="CallbackUrl connection property should be specified for OAuth Authentication" />
<api:script method="GET" >
<api:set attr="method" value="GET" />
<api:validate attr="_connection.Deployment" desc="To query this table User is required to be specified in the connection string." />
<api:null attr="CompanyId">
<api:set attr="ColumnRequired" value="CompanyId" />
<api:push op="apisadoThrowColumnRequiredException" />
</api:null> <api:set attr="uri" value="https://sample.url.value/[_input.companyIds]" />
<api:set attr="RepeatElement" value="/response" />
<api:call op="apisadoExecuteJSONGet">
<api:push/>
</api:call>
</api:script>
</api:script>
Mandatory Parameters That Must be Changed to Your Specific Values
Define the validation for your Company ID. This also shows the error message displayed in DataSync if one is not specified:
<api:validate attr="_input.CompanyId" desc="You must specify a CompanyId." />
Allow the back-end to detect any missing parameters. This value is what allows the RSD to display an error if a parameter is missing:
<api:null attr="CompanyId">
<api:set attr="ColumnRequired" value="CompanyId" />
<api:push op="apisadoThrowColumnRequiredException" />
</api:null>
Use the parameters in the URL:
Use the parameters in the URL:
[_input.companyIds]
DataSync User Interface
When you arrive in the table screen of an RSD file that is missing parameters, it will display the message shown in the image below:
The mandatory parameters that are missing filters are easy to locate in the RSD, as their desc (i.e., description) will tell you that you must specify a parameter. Changing any value overrides the previous value.
Editing Fields
If you try to enter the fields section without having a value specified for all mandatory filters, you will see the following pop-up message indicating that there are mandatory filters missing:
To correct this, use the SQL Expression Builder of the filter column (shown below) to fill in the mandatory parameters.
You can also use variables to fill in the values of the parameters as shown below.
Visualization of data using the magnifying glass icon is disabled if there are mandatory filters missing.