Skip to content

Template ​

Workflow and activity templates.

Endpoints ​

EndpointArgumentsReturns
v3.template.createtemplate: { description: string, global: boolean, processId?: string, configuration: any }HailerResult
v3.template.deletetemplateId: stringboolean
v3.template.gettemplateId: stringunknown
v3.template.listprocessId?: stringany[]
v3.template.previewdata: { activityId: string, templateId: string }unknown
v3.template.updateupdate: { 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):

FieldTypeRequiredDescription
descriptionstringnoDescription what this template is doing
globalbooleanyesIf global, allow all processes to use the template
fileTypepdf | csvyesAllowed filetypes: pdf, csv
contentstringyesScript to generate pdf, csv from
ownerCidsObjectId[]noNetworkIds for those who are allowed to edit template
configurationobjectnoconfiguration. Configuration for template. This will be copied to process.documentTemplates See below.
processIdObjectIdnoProcess Id to which this template belongs
cidObjectIdnoNetwork to which this template belongs

configuration (object):

FieldTypeRequiredDescription
namestringnoName of template
ordernumbernoDisplay order
fieldMapobjectnoSee below.
optsobjectnoSee below.

configuration.fieldMap (object):

FieldTypeRequiredDescription
staticActivityIdsstringnoUse data from any activities in template. Separate multiple ids with comma
imagesRecord<string, object>noImages to use in template See below.
activityLinksRecord<string, object>noLinked activities fields to use in pdf See below.
fieldsRecord<string, object>noFields from current activity and activitylinks See below.

configuration.fieldMap.images.* (object):

FieldTypeRequiredDescription
valuestringnoImageId
descriptionstringno

configuration.fieldMap.activityLinks.* (object):

FieldTypeRequiredDescription
labelstringno
processstringno
fieldstringno
descriptionstringno

configuration.fieldMap.fields.* (object):

FieldTypeRequiredDescription
valuestringno
labelstringno
descriptionstringno

configuration.opts (object):

FieldTypeRequiredDescription
formatFieldValuebooleannoUse formatted values like thousandSeparator and toFixedDigits
thousandSeparatorstringnoAny character to separate thousands with
decimalSeparatorstringnoAny character to use for decimal separator
toFixedDigitsstringnoEx: Use 2 for rounding to two digits
toFixedIdsstringnoProperty ids who will use the fixed digits
linkedActivitiesFilteredPhasesstringnoFiltered 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):

FieldTypeRequiredDescription
activityIdactivityIdyesId of activity
templateIdObjectIdyesId 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):

FieldTypeRequiredDescription
templateIdObjectIdyesId of template
descriptionstringnoDescription what this template is doing
globalbooleannoIf global, allow all processes to use the template
fileTypepdf | csvnoAllowed filetypes: pdf, csv
contentstringnoScript to generate pdf, csv from
ownerCidsObjectId[]noNetworkIds for those who are allowed to edit template
configurationobjectnoconfiguration. Configuration for template. This will be copied to process.documentTemplates See below.
processIdObjectIdnoProcess Id to which this template belongs
cidObjectIdnoNetwork to which this template belongs

configuration (object):

FieldTypeRequiredDescription
namestringnoName of template
ordernumbernoDisplay order
fieldMapobjectnoSee below.
optsobjectnoSee below.

configuration.fieldMap (object):

FieldTypeRequiredDescription
staticActivityIdsstringnoUse data from any activities in template. Separate multiple ids with comma
imagesRecord<string, object>noImages to use in template See below.
activityLinksRecord<string, object>noLinked activities fields to use in pdf See below.
fieldsRecord<string, object>noFields from current activity and activitylinks See below.

configuration.fieldMap.images.* (object):

FieldTypeRequiredDescription
valuestringno
descriptionstringno

configuration.fieldMap.activityLinks.* (object):

FieldTypeRequiredDescription
labelstringno
processstringno
fieldstringno
descriptionstringno

configuration.fieldMap.fields.* (object):

FieldTypeRequiredDescription
valuestringno
labelstringno
descriptionstringno

configuration.opts (object):

FieldTypeRequiredDescription
formatFieldValuebooleannoUse formatted values like thousandSeparator and toFixedDigits
thousandSeparatorstringnoAny character to separate thousands with
decimalSeparatorstringnoAny character to use for decimal separator
toFixedDigitsstringnoEx: Use 2 for rounding to two digits
toFixedIdsstringnoProperty ids who will use the fixed digits
linkedActivitiesFilteredPhasesstringnoFiltered 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.

Hailer Developer Documentation · v1.8.0