Appearance
Template
Workflow and activity templates.
Endpoints
| Endpoint | Arguments | Returns |
|---|---|---|
v3.template.create | template: { description: string, global: boolean, processId?: string, configuration: any } | HailerResult |
v3.template.delete | templateId: string | boolean |
v3.template.get | templateId: string | unknown |
v3.template.list | processId?: string | any[] |
v3.template.preview | data: { activityId: string, templateId: string } | unknown |
v3.template.update | update: { templateId: string, description?: string, global?: boolean, processId?: string, configuration?: any } | boolean |
v3.template.create
Description
Create document template. Returns created template
Parameters
Argument 1 (object, optional):
| Field | Type | Required | Description |
|---|---|---|---|
description | string | no | Description what this template is doing |
global | boolean | yes | If global, allow all processes to use the template |
fileType | pdf | csv | yes | Allowed filetypes: pdf, csv |
content | string | yes | Script to generate pdf, csv from |
ownerCids | ObjectId[] | no | NetworkIds for those who are allowed to edit template |
configuration | object | no | configuration. Configuration for template. This will be copied to process.documentTemplates See below. |
processId | ObjectId | no | Process Id to which this template belongs |
cid | ObjectId | no | Network to which this template belongs |
configuration (object):
| Field | Type | Required | Description |
|---|---|---|---|
name | string | no | Name of template |
order | number | no | Display order |
fieldMap | object | no | See below. |
opts | object | no | See below. |
configuration.fieldMap (object):
| Field | Type | Required | Description |
|---|---|---|---|
staticActivityIds | string | no | Use data from any activities in template. Separate multiple ids with comma |
images | Record<string, object> | no | Images to use in template See below. |
activityLinks | Record<string, object> | no | Linked activities fields to use in pdf See below. |
fields | Record<string, object> | no | Fields from current activity and activitylinks See below. |
configuration.fieldMap.images.* (object):
| Field | Type | Required | Description |
|---|---|---|---|
value | string | no | ImageId |
description | string | no |
configuration.fieldMap.activityLinks.* (object):
| Field | Type | Required | Description |
|---|---|---|---|
label | string | no | |
process | string | no | |
field | string | no | |
description | string | no |
configuration.fieldMap.fields.* (object):
| Field | Type | Required | Description |
|---|---|---|---|
value | string | no | |
label | string | no | |
description | string | no |
configuration.opts (object):
| Field | Type | Required | Description |
|---|---|---|---|
formatFieldValue | boolean | no | Use formatted values like thousandSeparator and toFixedDigits |
thousandSeparator | string | no | Any character to separate thousands with |
decimalSeparator | string | no | Any character to use for decimal separator |
toFixedDigits | string | no | Ex: Use 2 for rounding to two digits |
toFixedIds | string | no | Property ids who will use the fixed digits |
linkedActivitiesFilteredPhases | string | no | Filtered phases by processId for linked activities |
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.create', [
{
global: false, // If global, allow all processes to use the template
fileType: '...', // Allowed filetypes: pdf, csv
content: 'string', // Script to generate pdf, csv from
},
]);
console.log(result);Returns
HailerResult
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, retryAfter?, debug? }. retryAfter is a delay in milliseconds.
v3.template.delete
Description
Delete document template. Returns true if OK
Parameters
Argument 1 (ObjectId, required): templateId
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.delete', [
'507f1f77bcf86cd799439011', // ObjectId (required)
]);
console.log(result);Returns
boolean
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, retryAfter?, debug? }. retryAfter is a delay in milliseconds.
v3.template.get
Description
Get document template by id
Parameters
Argument 1 (ObjectId, required): templateId
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.get', [
'507f1f77bcf86cd799439011', // ObjectId (required)
]);
console.log(result);Returns
Undocumented
The return value is not described in the source yet.
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, retryAfter?, debug? }. retryAfter is a delay in milliseconds.
v3.template.list
Description
List templates
Parameters
Argument 1 (ObjectId, optional): processId
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.list', [
'507f1f77bcf86cd799439011', // ObjectId
]);
console.log(result);Returns
Array of any.
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, retryAfter?, debug? }. retryAfter is a delay in milliseconds.
v3.template.preview
Description
Get preview data for document template by activityId
Parameters
Argument 1 (object, optional):
| Field | Type | Required | Description |
|---|---|---|---|
activityId | activityId | yes | Id of activity |
templateId | ObjectId | yes | Id of template |
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.preview', [
{
activityId: '507f1f77bcf86cd799439011', // Id of activity
templateId: '507f1f77bcf86cd799439011', // Id of template
},
]);
console.log(result);Returns
Undocumented
The return value is not described in the source yet.
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, retryAfter?, debug? }. retryAfter is a delay in milliseconds.
v3.template.update
Description
Update document template. Returns updated document template
Parameters
Argument 1 (object, optional):
| Field | Type | Required | Description |
|---|---|---|---|
templateId | ObjectId | yes | Id of template |
description | string | no | Description what this template is doing |
global | boolean | no | If global, allow all processes to use the template |
fileType | pdf | csv | no | Allowed filetypes: pdf, csv |
content | string | no | Script to generate pdf, csv from |
ownerCids | ObjectId[] | no | NetworkIds for those who are allowed to edit template |
configuration | object | no | configuration. Configuration for template. This will be copied to process.documentTemplates See below. |
processId | ObjectId | no | Process Id to which this template belongs |
cid | ObjectId | no | Network to which this template belongs |
configuration (object):
| Field | Type | Required | Description |
|---|---|---|---|
name | string | no | Name of template |
order | number | no | Display order |
fieldMap | object | no | See below. |
opts | object | no | See below. |
configuration.fieldMap (object):
| Field | Type | Required | Description |
|---|---|---|---|
staticActivityIds | string | no | Use data from any activities in template. Separate multiple ids with comma |
images | Record<string, object> | no | Images to use in template See below. |
activityLinks | Record<string, object> | no | Linked activities fields to use in pdf See below. |
fields | Record<string, object> | no | Fields from current activity and activitylinks See below. |
configuration.fieldMap.images.* (object):
| Field | Type | Required | Description |
|---|---|---|---|
value | string | no | |
description | string | no |
configuration.fieldMap.activityLinks.* (object):
| Field | Type | Required | Description |
|---|---|---|---|
label | string | no | |
process | string | no | |
field | string | no | |
description | string | no |
configuration.fieldMap.fields.* (object):
| Field | Type | Required | Description |
|---|---|---|---|
value | string | no | |
label | string | no | |
description | string | no |
configuration.opts (object):
| Field | Type | Required | Description |
|---|---|---|---|
formatFieldValue | boolean | no | Use formatted values like thousandSeparator and toFixedDigits |
thousandSeparator | string | no | Any character to separate thousands with |
decimalSeparator | string | no | Any character to use for decimal separator |
toFixedDigits | string | no | Ex: Use 2 for rounding to two digits |
toFixedIds | string | no | Property ids who will use the fixed digits |
linkedActivitiesFilteredPhases | string | no | Filtered phases by processId for linked activities |
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.update', [
{
templateId: '507f1f77bcf86cd799439011', // Id of template
},
]);
console.log(result);Returns
boolean
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, retryAfter?, debug? }. retryAfter is a delay in milliseconds.