There are a couple of actions that can create comments and documents, or change rich text fields of an entity. All of these actions have a text area that supports the markdown template.

Markdown Basics

Fibery supports almost all features of the basic markdown syntax.

Please check this guide and apply it for actions with a markdown template. This is an example of a simple markdown template:

# Hello
Hi, **dear friend**. Nice to meet you.

This one will work for adding checklists

### My checklist
- [ ] Conquer markdown
- [ ] Procrastinate for the rest of the day

Using entity field shortcuts

You can use entity fields shortcuts in the template when there is a need to use some field values. The syntax of the shortcut is {{Field Name}}. Use "." when you are going to put a relation field into the template: {{Relation Name.Field Name}}.

Here we will get the entity Name and its State Name:

# My name is {{Name}}!
My current status is {{State.Name}}

Using one-to-many or many-to-many field shortcuts

There is a way to include entity collections into the output document: {{Collection Name:Field1,Field2,...,FieldN}}. The result of the collection shortcut is a table.

Let's say Story has a collection of Bugs. You can print them into a document like this:

## Quick Overview of {{Name}}

Current state is **{{State.Name}}**.

### Bugs
{{Bugs:Name, State.Name}}

1. We created a button with "Add comment" action

2. The result of the button click:

Using javascript code and Fibery API in templates

Javascript code and Fibery API can be used in templates. Javascript code can be executed using <% const sample = 1; %> syntax. You may place output from your code into the template using <%= sample%> syntax.

An entity can be referenced as Entity if you would like to make some calls to fibery API and retrieve some additional data. Entity contains Id and Type properties.

Here is an example of using Javascript and fibery API in a template.

### Overview of assignees
<%= Entity.Type %> (#<%= Entity.Id%>)

#### Assignees
<%
const fibery = context.getService('fibery');
const entityWithAssignees = await fibery.getEntityById(Entity.Type, Entity.Id, ['Assignees']);
entityWithAssignees.Assignees.forEach((assignee) => {
%>
- <%= assignee.Name %>
<% });%>

Date of comment: <%= new Date()%>

The output of this template if it is used for "Add Comment" action can be found below

NOTE: Templates javascript code can have some limitations due to security reasons.

Happy templating, dear friends. Let us know if any questions.

Did this answer your question?