Forms
Read a report-document snippet
/a/Form_getSnippet
Fetch an installed HTML building block for a report-document editor.
When to use this endpoint
Obtain fname from Forms_listSnippets, then load the chosen block for insertion into the report document. This retrieves deployment files, not a tenant-authored form block or a rendered report.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session and is scoped to the authenticated tenant.
The handler performs no form, department, owner, or page-permission check unless the page below says otherwise. CRM navigation may impose additional UI-only access rules.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fname | Relative snippet path string | Yes | Nonempty path containing .html and no .. substring. The guard checks for .html anywhere, not necessarily a final extension. Use the exact path returned by Forms_listSnippets, including any leading slash. |
Example request
$snippet = FM_api('Form_getSnippet', ['fname'=>'/Company Details/Client Only/Name-Address/Name_Address.html']);
Example response
{"ok":1,"snippet":"<p>Company details</p>"}
snippet is the installed file’s raw text; the example illustrates its envelope, not the exact contents of the chosen deployment file. It is not server-rendered with customer/job values.
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: fname"} | Missing/null/false-like, contains .., or lacks .html. |
{"error":"file does not exist"} | Resolved file below the report-styles blocks directory does not exist. |
{"error":"file is not readable"} | Exists but PHP cannot read it. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- The file path is rooted at report-styles/www/blocks. There is no tenant-specific lookup, template-variable substitution, type filtering, size cap or pagination in this endpoint.
- The file is checked before file_get_contents; a later read failure is not checked separately and can yield ok=1 with snippet=false. Missing deployment assets fail even when a name exists elsewhere.
- An unused nested curl_load helper is declared but never invoked by the snippet path; this endpoint does not fetch a remote URL. Repeated handler invocation in one PHP process can collide on that helper declaration.
- No direct mobile app/m-service caller for this RPC was found. Mobile form definitions arrive through m’s syncDownloads form channel, not this endpoint.
Side effects
- Reads a local report-style asset only. No database changes, cache/history, remote requests or report generation.
See it in Fieldmotion
CRM1
Report Document editor → snippet palette calls Forms_listSnippets; choosing a block requests Form_getSnippet and appends snippet to the document editor.
CRM2
No direct production Form_getSnippet caller found. Its Report Document editor shares the report design workflow but source search found no matching RPC.
Related endpoints
Forms_listSnippetsenumerates exact installed snippet paths.FormBlocks_listlists tenant-authored reusable form blocks instead.