Technical¶
Components in the package¶
Document Templates use the following components in Lime CRM:
- Web components
- Web client commands
- Custom endpoints
- Lime Admin config
- Admin CLI
Commands¶
Document templates listens to two webclient commands:
CreateLimeobjectDialogCommand
which is dispatched when someone tries to start the create a new limeobject UI workflow.- We listen to this command to determine if we need to show the dialog with the template picker before the create document dialog.
SaveLimeObjectCommand
which is dispatched when someone tries to save a new limeobject after entering in all the info for that limeobject.- We listen to this command to determine if we need to save the document limetype via our custom endpoint so that the template is generated during limeobject creation.
Internal endpoints¶
List templates¶
GET
Returns all templates that can be used.
Payload:
limetype
can be any limetype. When the value is set (not null
), this limetype is used to filter for all templates
where this limetype is listed in the Restrict to lime types
list in the template configuration in Lime Admin.
extension
can only be set to docx
.
Response:
Note: The first item in the list is a web client template while the second is a desktop template,
the desktop template would NOT be returned if Use Desktop Templates
is unchecked in Lime Admin.
[
{
"extension": "docx",
"id": 59903701,
"last_modified": "2021-05-03T09:37:25.897000",
"mimetype": "application/octet-stream",
"filename": "template example.docx",
"size": 14026,
"storage_type": "sql",
"filetype": 115,
"metadata": {
"tags": [],
"limetypes": [
"project"
],
"locale": "en_US",
"locale_display_name": "English (United States)",
"active": true,
"template_id": "project-example"
}
},
{
"extension": "docx",
"id": 30190701,
"last_modified": "2014-04-28T11:46:18.263000",
"mimetype": "application/octet-stream",
"filename": "desktop template example.docx",
"size": 1725661,
"storage_type": "sql",
"filetype": 113,
"metadata": {
"category": "Sälj",
"name": "desktop template example"
}
}
}
Save template¶
POST
Saves a template.
Payload (Form Data):
options
is stringified JSON that, if exists, should only contain the key migrate
. If migrate is true
, the file will be migrated from a desktop to webclient template before it is saved.
Response:
Delete unused templates¶
DELETE
Deletes all unused webclient document templates. Does not delete desktop templates.
Response:
Create document¶
POST
Creates a document from a template.
Payload:
An object containing the values of the create document form. The below example will be different for different CRM systems.
The property configured in Lime Admin as the Document Property
should be populated with null
since that property will
be populated with the new file generated from the template.
Template merge codes are populated from this data and the relations set on this object (i.e. coworker.email
would return the email property of
the coworker with id 19601).
{
"coworker": 19601,
"document": null,
"date": "2021-05-03T07:50:55.098Z",
"person": null,
"description": "test",
"company": null,
"project": null,
"projectactivity": null,
"signing": null
}
Response:
Get template¶
GET
Returns a template.
Response:
A file streamed as application/octet-stream
.
Delete template¶
DELETE
Deletes a template.
Note! This deletes the actual template file, not the configuration entry in Lime Admin. This action is non-recoverable!
Response:
No response, returns a HTTP status code 204 on success.
Validate template¶
POST
Validates a template.
Payload (Form Data):
Response:
If valid:
If invalid:
ErrorCode can be one of "UnsupportedExtension"
, "Unparsable"
or "LegacyTemplate"
.
Zombie files¶
Template files are not deleted when a configuration entry is deleted in Lime Admin. This allows for the potential recovery of important documents.
This package provides a CLI
tool for removing these zombie files. It will delete all web client document templates that do not have an entry
in the Lime Admin configuration.
Be sure to run this command in the Lime CRM Terminal.