Click or drag to resize
[Template] section
Print this page

The [Template] section contains general information about the template.

Entries are case-sensitive.

Tip Tip

Except where noted, you can pass these template properties via query string, which lets you override or supplement values at run-time. This technique lets you avoid creating new template variants for one-off runs. For example, if you want to retrieve data to XML format just once, you can use a template that retrieves CSV and add your override properties to the call:

https://acme.api.telogis.com/execute?template=12345&...&Format=XML&ElementName=TableEntry

This topic contains the following sections:

Required entries

Each of your templates must include the following entries in its [Template] section:

EntryDescription
TemplateVersion (cannot be passed on the query string) The version of the template syntax. The current version is 1.0.
TableID (cannot be passed on the query string) The Symbolic Name (unique identifier) for a version of one of the TDETables.
TemplateName (cannot be passed on the query string) The name of the template. This name must be unique because it is used for identifying template files when using the Web Service. When exporting to XPath format, the TemplateName is the name of the root element.
Intent Indicates what action the template performs when run. Possible values are:
  • Retrieve - Retrieve data from the TDE table into a file.
  • Create - Create data in the TDE table.
  • Update - Update data in the TDE table.
  • CreateOrUpdate - Update data in the TDE table if the row exists, create it if it doesn't.
  • Delete - Delete data from the TDE table.
See Tables to verify which intents are supported for your target table.
Tip Tip

"Input" template intents are those that use an input file: Create, Update, CreateOrUpdate, and Delete.

Delimiter (optional for the default value, comma) The delimiter that divides columns in your input or output CSV file.
Tip Tip

The delimiter can be multiple characters long (e.g. "Delimiter=~~"), and a tab character is denoted as "\t".

Optional entries - Input
EntryDescription
GroupBy On Create, Update, or CreateOrUpdate templates, the column(s) to use for grouping inserted data. When data is grouped, only a single row is created or updated for each group (combination of grouping column values) in the input data. Note that for output values that are generated from columns other than the grouping columns, the input data that is used is from an arbitrary row within the group, unless you use accumulator functions to summarize the data from a column over all the values in the group.
OrderBy (defaults to no ordering) The column(s) to use for sorting input data. The sort direction defaults to ascending, however, the direction can be explicitly specified by adding either ASC or DESC following the name of the column to be sorted. Examples:
  • Defaults to ascending order:

    OrderBy = Input.Time

  • Sorts input data into descending order:

    OrderBy = Input.Time DESC

  • Sorts input data into a mix of ascending and descending order:

    OrderBy = Input.UnitId ASC, Input.StartTime DESC, Input.EndTime DESC

IgnoreValue By default, TDE writes all incoming values (including empty ones) to the table. For CSV input data, if you want to direct TDE to ignore empty input fields and preserve any existing values, specify this line in your template:
IgnoreValue=""
For XML and JSON input data, it's even easier: simply omit values to have them ignored. In JSON, a property with a null value will also be ignored.
Tip Tip

You can also specify a string that should be skipped, such as IgnoreValue="(null)".

InputHeader (defaults to true) For templates that define an input (create or update) action, this indicates whether the imported file includes a header row. When true, the first line of the CSV file is interpreted as the column names. When false, the template must include a [Columns] section to supply the column names for the input CSV file.
Output Indicates how to handle input data that contains errors. Possible values are:
  • CompleteSuccessful - (default) Commit valid rows and reject invalid rows. That is, the operation can succeed partially.
  • CompleteAll - (currently unsupported) All rows must succeed in order to commit changes. That is, the entire operation succeeds or fails as a whole.
Format The format of the input data. Values:
  • CSV - (default) The input data is in CSV (comma-separated value) form.
    Tip Tip

    You can use the Delimiter entry to specify a different delimiter character.

    Note Note

    In CSV files, stray spaces before the first quote of delimited fields can corrupt the parsing of those values.

  • FixedWidth - The input data is a fixed-width text file. To import using fixed-width format, you must include a [Columns] section to specify the column widths.
  • XPath - The input data is XML. Use the ElementName attribute to specify which node to input. If you do not specify an ElementName, the string "TableEntry" is used. If your template maps to an element that is not present in your input data, then the element will be ignored. See the [Output] section for more details on how to access your data from the template.
    Note Note

    If your input file contains any namespaces, you must define these in the [Namespaces] section.

  • JSON - The input data is JSON. Each record of the output is a node specified by the ElementName. If you do not specify an ElementName, the string "TableEntry" is used. If your template maps to an element that is not present in your input data or is set to null, the element will be ignored. See the [Output] section for more details on how to access your data from the template.
    Note Note

    If your input is a JSON array, the ElementName must be specified, and it must be blank, like "ElementName="

ElementName The name of the base element for each row when inputting XPath or JSON formats. The default value is "TableEntry". Note that you can use ElementName to provide a table name as well as a row element name. For example, setting ElementName=Result/Location in a template for either of the inputs shown below will make the input records be the "Location" elements:
XML
<Result>
<Location id="87979363" Number="5186" Street="W 142nd St"
CityName="Hawthorne" State="California" Zip="90250" Radius="500" />
<Location id="87979591" Number="85" Street="Enterprise Ave"
CityName="Aliso Viejo" State="California" Zip="90250" Radius="250" />
</Result>
JSON
{
  "Result":{
    "Location":[
      {
        "id":"87979363",
        "Number":"5186",
        "Street":"W 142nd St",
        "CityName":"Hawthorne",
        "State":"California",
        "Zip":"90250",
        "Radius":"500"
      },
      {
        "id":"87979591",
        "Number":"85",
        "Street":"Enterprise Ave",
        "CityName":"Aliso Viejo",
        "State":"California",
        "Zip":"90250",
        "Radius":"250"
      }
    ]
  }
}
Commit (defaults to true) Indicates whether your input data will be created in the TDE table. When true, your data will be committed, when false, your data is not committed and is instead only validated. If you only want to test the validity of your input, then set Commit to false. The response will confirm which Commit mode the template is running in.
KeyLookupFailuresAsErrors (defaults to true) When an external key or Telogis key lookup fails, this setting indicates whether an error should be returned. When set to true, an error is returned indicating that the lookup failed. When set to false, a 0 is returned instead of an error. We do not recommend setting this entry to false, but the option is available if needed for legacy templates.
CaseSensitiveFields

(defaults to false) Indicates whether TDE considers case when processing templates. If set to true, template syntax is considered case sensitive.

For example, if your template is for a table with a DriverId column, you must specify Input.DriverId for driver Id input. If you specify case inconsistently, for example Input.driverid, input.driverid, or input.DriverId, TDE returns a "Table column not found" error code.

Setting this option turns on stricter validation of template syntax which can be useful for tables that have custom properties with case differences, for example CustomProp1 and customProp1. If the CaseSensitiveFields option is set to false, TDE cannot reliably retrieve the correct value. If the CaseSensitiveFields option is enabled, CustomProp1 references the value in that property instead of the one specified by customProp1.

Optional entries - Retrieve
EntryDescription
OrderBy (defaults to no ordering) The column(s) to use for sorting retrieved data. The sort direction defaults to ascending, however, the direction can be explicitly specified by adding either ASC or DESC following the name of the column to be sorted. Examples:
  • Defaults to ascending order:

    OrderBy = Input.Time

  • Returns results in descending order:

    OrderBy = Input.Time DESC

  • Returns results in a mix of ascending and descending order:

    OrderBy = Input.UnitId ASC, Input.StartTime DESC, Input.EndTime DESC

OutputHeader (defaults to true) For templates that define a retrieve action, this indicates whether the generated file includes a header row.
  • For CSV output: When set to true, a header line is generated. When false, no header line is included.

  • For JSON output: When set to true, the table name is the key to the result array. When false, no table name key is included, and the result is an array of JSON objects.

FilterTeleportedPoints (defaults to true; Point table only) By default, TDE filters out points with invalid (teleported) changes in location; you can retrieve such points by setting FilterTeleportedPoints = false.
Format The format of the output when the Intent is "Retrieve". Values:
  • CSV - (default) Export to CSV (comma-separated value).
    Tip Tip

    You can use the Delimiter entry to specify a different delimiter character.

  • FixedWidth - Export a fixed-width text file. To export to fixed-width format, you must include a [Columns] section to specify the column widths.
  • XML - Export to XML format. When exporting to XML, the values are returned as attributes of the XML object. You can use ElementName to specify the XML element that is used for each record that is exported. If you do not specify an ElementName, the string "TableEntry" is used, as shown here:
    XML
    <TableEntry id="87979363" Number="5186" Street="W 142nd St" CityName="Hawthorne" State="California"  Zip="90250" Radius="500" />
  • XPath - Export to XML using the XPath provided to describe the document. When exporting to XPath, by default values are returned as elements, although in the [Output] section you can specify that specific values should be returned as attributes using XPath syntax. The root element is given by the TemplateName, and each record of the output is inserted at the node indicated by ElementName. If you do not specify an ElementName, the string "TableEntry" is used, as shown here:
    XPath
    <TableEntry>
    <id>87979363</id>
    <Number>5186</Number>
    <Street>W 142nd St</Street>
    <CityName>Hawthorne</CityName>
    <State>California</State>
    <Zip>90250</Zip>
    <Radius>500</Radius>
    </TableEntry>
  • JSON - Export to JSON format. When exporting to JSON format, the root element is given by the TemplateName, and each record of the output is inserted as a property indicated by ElementName. If you do not specify an ElementName, the string "TableEntry" is used, as shown here:
    JSON
    {
      "TableEntry":{
        "id":"87979363",
        "Number":"5186",
        "Street":"W 142nd St",
        "CityName":"Hawthorne",
        "State":"California",
        "Zip":"90250",
        "Radius":"500"
      }
    }
ElementName The name of the base element for each row when exporting to XML, XPath, or JSON format. The default value is "TableEntry". Note that you can use ElementName to provide a table name as well as a row element name. For example, "ElementName=Result/Location" produces output such as:
<Result>
<Location id="87979363" Number="5186" Street="W 142nd St"
CityName="Hawthorne" State="California" Zip="90250" Radius="500" />
<Location id="87979591" Number="85" Street="Enterprise Ave"
CityName="Aliso Viejo" State="California" Zip="90250" Radius="250" />
</Result>
JSON
{
  "Result":{
    "Location":[
      {
        "id":"87979363",
        "Number":"5186",
        "Street":"W 142nd St",
        "CityName":"Hawthorne",
        "State":"California",
        "Zip":"90250",
        "Radius":"500"
      },
      {
        "id":"87979591",
        "Number":"85",
        "Street":"Enterprise Ave",
        "CityName":"Aliso Viejo",
        "State":"California",
        "Zip":"90250",
        "Radius":"250"
      }
    ]
  }
}
Newline

(only applies to CSV and FixedWidth formats) By default, TDE inserts Windows-style line breaks (\r\n) after each row of data retrieved for CSV and FixedWidth formatted outputs. However, you can use the Newline entry to override the default line break style or add characters at the end of the line.

Line break examples:

  • Newline = \r\n - (default) Inserts Windows-style line breaks.
  • Newline = \r - Inserts Mac-style line breaks.
  • Newline = \n - Inserts Unix-style line breaks.

If you use the Newline entry to insert additional characters at the end of each line, we recommend ending the character string with \r\n (or your preferred line break style) to break the line following your character string. For example, Newline = |\r\n inserts a pipe followed by a Windows-style line break after each row of data.

StructuredData

(defaults to false) Setting StructuredData to true allows some data types to be output in a standard structure for JSON and XPATH formats. When set to false, TDE outputs the structured data types below as follows:

  • The Location data type outputs as a space separated Latitude and Longitude pair.
  • The Address data type outputs as a | (pipe) delimited string.
  • The Set and Array data types output as a comma delimited string.
  • The Map data type also outputs as a comma delimited string, but only when you retrieve an individual item within the map object by key.
  • Tip Tip
    To retrieve a complete Map object (instead retrieving an item in the map by key), then StructuredData must be set to true.

In the example outputs below, AccessDays is a Set. In the first example, the output is for a template in which StructuredData is set to false; therefore, the AccessDays data is output as a comma-delimited string.

JSON, StructuredData=false
{
  "RetrieveUserAccessDaysTemplate": {
    "TableEntry": [
      {
        "Id": "123456",
        "AccessDays": "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"
      },
      {
        "Id": "345678",
        "AccessDays": "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"
      }
    ]
  }
}

When StructuredData is set to true, the AccessDays data is output in a standard structure.

JSON, StructuredData=true
{
  "RetrieveUserAccessDaysTemplate": {
    "TableEntry": [
      {
        "Id": "123456",
        "AccessDays": [
          "Sunday",
          "Monday",
          "Tuesday",
          "Wednesday",
          "Thursday",
          "Friday",
          "Saturday"
        ]
      },
      {
        "Id": "345678",
        "AccessDays": [
          "Sunday",
          "Monday",
          "Tuesday",
          "Wednesday",
          "Thursday",
          "Friday",
          "Saturday"
        ]
      }
    ]
  }
}

See the Accessing subfields page for another example.

CaseSensitiveFields

(defaults to false) Indicates whether TDE considers case when processing templates. If set to true, template syntax is considered case sensitive.

For example, if your template is for a table with a DriverId column, you must specify Input.DriverId for driver Id input. If you specify case inconsistently, for example Input.driverid, input.driverid, or input.DriverId, TDE returns a "Table column not found" error code.

Setting this option turns on stricter validation of template syntax which can be useful for tables that have custom properties with case differences, for example CustomProp1 and customProp1. If the CaseSensitiveFields option is set to false, TDE cannot reliably retrieve the correct value. If the CaseSensitiveFields option is enabled, CustomProp1 references the value in that property instead of the one specified by customProp1.