Reusable document and recurrence templates
Read the legacy template settings table
/a/Templates_getDT
Load the legacy recurrence-template settings table
When to use this endpoint
Use for CRM1’s older template table, whose data rows are positional arrays. For a picker use Templates_get; for field-mapped objects use Templates_getDataTable. The request/response contracts are not interchangeable.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. Template_get, Template_new, Template_setObj and Templates_get require an authenticated tenant context; Template_delete and both table handlers also call the login guard. There is no handler-level administrator, page, role, creator or ownership check.
Templates are shared within the authenticated tenant, not private to created_by. There is no user, department, feature-setting or active/deleted filter. The dispatcher also applies its normal account, authentication and team-access checks; the shared table predicate adds no template-specific row restriction.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
obj_type | Integer | Yes | Non-null presence required, then integer-converted; zero/negative values are not rejected. Restricts all row and total-count queries to this type. |
draw | Integer | Yes | Non-null presence required; integer-converted and echoed. Not a page number. |
start / length | Integers | Supply both | Zero-based offset and SQL row limit. Both are directly integer-converted without positive-range checks, defaults or cap; omitted values reach legacy undefined-key handling and effectively zero. Use nonnegative start and positive length. |
order[0][column] / order[0][dir] | Nested form fields | Supply both | Column 0 sorts name, 1 sorts created_by, 3 sorts obj; anything else sorts name. Only exact desc means descending, otherwise ascending. These sort indexes do not correspond directly to the five returned row positions. |
name | String | No | Presence adds lower(name) LIKE %value%. Input is not trimmed or lowercased; SQL collation affects case matching. % and _ retain wildcard meaning. No generic DataTables search[value] filter is read. |
Example request
$table = FM_api('Templates_getDT', [
'obj_type' => '1',
'draw' => '1',
'start' => '0',
'length' => '10',
'order' => [['column' => '0', 'dir' => 'asc']],
]);
Example response
{"data":[["1042","Weekly visits","1792832400","1088","{\"notes\":\"Visit notes\"}"]],"draw":1,"recordsTotal":1,"recordsFiltered":1}
Each row is [id,name,cdate,created_by,obj]. cdate is raw Unix seconds, created_by is a user ID rather than a joined name, and obj remains JSON text. draw and counts are integers. data=[] on no matches; counts ignore the page limit. recordsTotal is already type-scoped, while recordsFiltered also includes name.
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error":"missing or invalid parameter: obj_type"} | Type absent/null. |
{"error":"missing or invalid parameter: draw"} | draw absent/null. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Ordering has no ID tiebreaker; offset pages are not stable snapshots. The handler has no maximum page size or length=-1 “all rows” conversion. Invalid limits can cause query failure rather than a validation error.
- No creator/user restriction, automatic deleted filter or tenant setting is added. Supplied fields and isTable do not alter the fixed five-value row shape.
- No direct mobile-app or m-service caller for this template family was found in the source search. The CRM2 widget’s payload is client-defined; storing it does not validate that another document endpoint will accept every field.
Side effects
- Only reads template rows and counts.
See it in Fieldmotion
CRM1
In CRM1 Settings → Job settings, open the recurrence-template table. Filter requests for Templates_getDT; its DataTables caller supplies obj_type=1, paging/draw/order and removes columns from the request.
CRM2
No production CRM2 caller for Templates_getDT was found. CRM2 uses Templates_get for its reusable-template widgets and recurrence picker.
Related endpoints
- Templates_get supplies the selectable presets for one type.
- Template_get reads one stored preset without applying it.
- Template_new creates a separate preset; Template_setObj replaces an existing preset’s payload.
- Template_delete removes the reusable preset, not documents previously created from it.