Previous Page Arrow Next Page Arrow

12.4 Named Query Template

A named query MAY have a $template URL. If so, a GET operation on the $template URL will return default values for the query parameters. For example:

GET /sdata/myApp/myContract/-/products/$queries/reorder/$template

Returns:

200 OK
Content-Type: application/atom+xml; type=entry
 
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <id>http://www.example.com/sdata/myApp/myContract/-/products/$queries/reorder</id>
  <sdata:payload>
    <productReorder xmlns="http://schemas.sage.com/myContract">
      <request>
        <threshold>5</threshold>
      </request>
    </productReorder>
  </sdata:payload>
</entry>

This URL is useful if the query is invoked via a form. It allows the SData consumer to easily fill the form with meaningful default values. In the example above, the consumer will use 5 as default value for the threshold field.

The service schema MUST advertise the presence of a $template URL on named queries. This is done by setting the sme:hasTemplate attribute to true on query elements.

SData providers MAY support $template URLs on named queries. If so, they MUST advertise it with an sme:hasTemplate attribute in the schema.

Previous Page Arrow Next Page Arrow