On most fields of type script, config
variable is available
{{ config.siteUrl }} {# config is system configuration object #}
isNew(Entity entity)
boolean
{% if isNew(product) %}
<span class="badge">New Item</span>
{% endif %}
createEntity(string entityType, array data)
{% set newProduct = createEntity('Product', {name: 'Test'}) %}
findEntity(string entityType, array where)
null
{% set user = findEntity('User', {name: 'john doe'}) %}
findEntities(string entityType, array where, string orderField = 'id', string orderDirection = 'ASC', int offset = 0, int limit = \PHP_INT_MAX, bool withDeleted = false)
{% set activeUsers = findEntities('User', {isActive: true}) %}
md5(string value)
string
(32-character hexadecimal hash){% set hashedPassword = md5('mySecretPassword') %}
parseMarkdown(string markdownText)
string
(HTML-rendered text){% set htmlContent = parseMarkdown('# Title\nMarkdown content') %}
convertFileToBase64FromUrl(string url, ?string type = null)
string
(Base64 representation){% set base64File = convertFileToBase64FromUrl('https://example.com/document.pdf') %}
convertFileToBase64(Entity file)
string
(Base64 representation){% set base64File = convertFileToBase64(file) %}
getConvertedImageUrl(Entity image, array options = {quality: 100, format: 'jpg'})
string
(Transformed image URL){% set thumbnailUrl = getConvertedImageUrl(product.files[0]) %}
translate(string key, string languageCode = 'en_US', string category = 'labels', string scope = 'Global')
string
(Translated text){% set nameLabel = translate('name','en_US','fields','Product') %}
translateOption(string key, string languageCode, string field, string scope = 'Global')
string
(Translated option label){% set statusLabel = translateOption('draft', 'en_US', 'status', 'Product') %}
getAllLanguageFields(entityType, string|array fields)
array
of language fields{% set languageFields = getAllLanguageFields('Product', fields) %}
getProductAttributeValue(string attributeId, string channelId = '', string language = 'main')
pav()
{% set color = getProductAttributeValue(product, 'color') %}
formatProductAttributeValue(Entity pav)
formatPAV()
{% set formattedPrice = formatProductAttributeValue(product.price) %}
isAttributeChanged(Entity entity, string attributeName)
boolean
{% if isAttributeChanged(user, 'email') %}
{# Attribute was modified #}
{% endif %}
getFetched(Entity entity, string attributeName)
{% set originalEmail = getFetched(user, 'email') %}
formatField(Entity entity, string field)
{% set formattedDate = formatField(user, 'createdAt') %}
ai(string engine, string prompt)
{% set productDescription = ai('chatgpt','Generate a description for a luxury watch') %}
getPreviousCategoryId(Entity category)
prepareEntity
{% set processedEntity = product|prepareEntity %}
{{ processedEntity.name }}
prepareHtmlField
{% set safeContent = article.description|prepareHtmlField %}
{{ safeContent|raw }}
isImage
{% set validImage = uploadedFile|isImage ? uploadedFile : defaultImage %}
<img src="{{ validImage }}" alt="Product Image">
escapeDoubleQuote
{% set safeName = product.name|escapeDoubleQuote %}
<div title="{{ safeName }}">{{ product.name }}</div>
escapeStr
{% set sanitizedComment = user.comment|escapeStr %}
{{ sanitizedComment }}
backslashNToBr
{% set formattedDescription = user.description|backslashNToBr %}
<p>{{ formattedDescription|raw }}</p>
generateBorderColor
{% set borderStyle = product.category|generateBorderColor %}
<div style="border: 2px solid {{ borderStyle }}">{{ product.name }}</div>
generateFontColor
{% set textColor = status|generateFontColor %}
<span style="color: {{ textColor }}">{{ status }}</span>
You cannot use php syntax there, because it is rendered in javascript context.
entity
: Entity being modifiedentityFrom
: Entity from which new entity is being created (in modal view)Example:
Give me a description for a product with the name {{ entity.name }}
entity
: Entity being modifiedentityFrom
: Entity from which new entity is being createdExample:
{"description": "{{ 'Description of ' ~ entity.name }}"}
entity
: First Entity of the collection to exportsourceEntities
: Collection of entities to exportsourceEntitiesIds
: Array of entity IDs to exportExample:
{# Export payload processing #}
{"where":[{"type":"in","attribute":"id","value":{{ sourceEntitiesIds|json_encode|raw}}}]}
entity
: Entity to be updatedtriggeredEntityType
: Entity Type of the entity that triggered the updatetriggeredEntityId
: ID of the entity that triggered the updatetriggeredEntity
: Entity that triggered the updateExample:
{
"description": "{{ entity.name }} - {{ entity.brand.name }}",
}
entity
: Source EntitytriggeredEntityType
: Entity Type of the entity that triggered the updatetriggeredEntityId
: ID of the entity that triggered the updateExample:
[
{
"entity": "Product",
"payload": {
"name": "{{ entity.name }}-Duplicated"
}
}
]
entity
: Source EntityExample:
Action cannot be performed on product {{ entity.name }}
entities
: Collection of entities to exportExample:
[
{% for entity in entities %}
{"name": "{{ entity.name }}"}{% if not loop.last %},{% endif %}
{% endfor %}
]
feed
: Feed Datafilename
: Default filename generated by the systeminteration
: Job iteration numberExample:
{# Custom filename generation #}
{{ feed.name }}_{{ filename }}_{{ interation }}
entity
: Entity that triggers the workflowuser
: User that triggered the workflowimportJobId
: ID of import job if workflow is triggered during an importExample:
{{ entity.isActive and user.id != 'system' and importJobId is empty }}
The Monaco field provides intelligent suggestions: