Closed wangweiyi722 closed 6 months ago
In summary, we would like to understand in what cases dotCMS is able to evaluate the functions and variables, and in what cases dotCMS is not. I have not been able to achieve behavior consistent with what the customer reported. They are only running the workflows via the content edit modal, but the dotcontent.find viewtool is still only sometimes being evaluated.
After some internal discussion we have some guidelines regarding how to load categories in velocity code executed in a workflow action:
$workflow
variable intended use is for retrieving properties related to the workflow action, not properties for the content, for example:
contentletDependencies
property is included in the $workflow
variable properties, because there is another variable '$content' that can be used to retrieve the content identifier, and then the $dotcontent
velocity tool can be used to retrieve a content map with all the content properties.#set($contentMap = $dotcontent.find($content.identifier))
<h4>$!{contentMap.title}</h4>
<ul>
#foreach($cat in $contentMap.productName)
<li><b>Category Name:</b> $!{cat.categoryName}</li>
<ul>
<li><i>Category Key:</i> $!{cat.key}</li>
<li><i>Velocity Variable Name:</i> $!{cat.categoryVelocityVarName}</li>
</ul>
#end
</ul>
The $workflow
velocity variable for workflow subsections that execute velocity code isn't documented here:
Velocity Script Sub-Action
We can include the documentation for the '$workflow' variable and its properties in this page.
Also, some workflow subactions, like the 'Send Form Email' subsection, include other velocity variables for so the user can access some properties without using the $workflow
variable properties. For example: $workflowMessages, $stepName and $actionName. We can do some code changes to use the same variables in all the subactions that execute velocity code, that way we will have a consistent velocity context for all the subactions.
Closed in favor of: https://github.com/dotCMS/core/issues/28352
Parent Issue
No response
Problem Statement
When running velocity code as part of a workflow subaction, some functions and properties in the code do not get evaluated into values, but are treated as strings instead.
Steps to Reproduce
Create a content type with a category field Create a workflow with a step that includes a large message subaction which populates the content based on a vtl Create a content of the content type In the content search menu, select the content in question > available workflows > run the workflow step The large message that is displayed will have some of the content fields and functions unpopulated Go to the same content, and actually open the content edit modal. Run the workflow from the content edit modal The large message that is displayed will have all of the content fields
Acceptance Criteria
Make the workflows consistently populate velocity variable values
dotCMS Version
23.01.12
Proposed Objective
Technical User Experience
Proposed Priority
Priority 2 - Important
External Links... Slack Conversations, Support Tickets, Figma Designs, etc.
https://dotcms.zendesk.com/agent/tickets/115127
https://github.com/dotCMS/core/assets/25590931/c9f7168b-6b77-4675-baba-a7bd21427746
Assumptions & Initiation Needs
No response
Quality Assurance Notes & Workarounds
No response
Sub-Tasks & Estimates
No response