Skip to main content
Skip table of contents

HTML Logic

The HTML resources in Dynamo templates, be they Screens or document parts, can contain HTML content commands as elements and attributes among the standard HTML elements and attributes. Similar to the commands in a Flow, each content command has its own intrinsic function that it performs when evaluated. These commands also have attributes, or secondary attributes in the case of content commands that themselves appear as attributes, that configure their effects exactly in the same way as attributes of other commands do, so the topics of Variables and Attributes apply here as well. However, as content commands exist only to modify the content they're in, they do not generate any variables into the variable context the evaluation occurs in, which is the variable context that is active when the HTML resource's evaluation starts.

A trait common to all content commands is that they can only affect their host element - the one they're placed in - and its contents. Therefore the placement of these commands in the HTML is key in making proper use of them. The use of content commands also asks for some knowledge of HTML in general, as they can set standard HTML attributes, which may not be valid on certain host elements, and modify the structure by removing or multiplying elements.

In the Template builder's editor of HTML resources, you can find the content commands in the right-side panel's Element view, labeled with "Content Commands" as shown below. Note that the value defined for the "Content" command below is actually referring to a variable despite lacking the typical ${} EL notation - in evaluation of HTML resources, the system allows for more compact EL expression notation by filling out the ${ and } around the expressions automatically during the evaluation process if they are not already there. However, you may still use them in the attribute value, to combine text with a variable for example, like Hello ${Account.Owner.Name} - in this case the system would detect the expression start and end symbols being present and not add them.

image-20240110-143825.png

The editor's Content commands view provides an easy way to set and modify the commands, but you can also do it directly in the Source view if you like. That "Content" command appears in the HTML source as an attribute called dyn-content. Below is the source view matching the previous image, displaying a span that has this content command set into it. All the Dynamo content command attributes and elements can be recognized by the "dyn-" prefix. This prefix is not considered to be part of the content command's name, so if looking for this command's documentation, look for content, rather than dyn-content.

HTML evaluation

The evaluation of content commands occurs when the HTML resource in which they are in is evaluated, which happens at a time dependent on the role of the HTML resouce.

  • An HTML resource that is being used as a Screen undergoes evaluation when the evaluation process is starting a Screen step displaying that Screen.

  • An HTML resource being used as a document undergoes evaluation when a composeContent command handling that resource is evaluated.

In both cases the same resource may be evaluated multiple times as the original resource remains intact throughout the evaluation process. For example, a particular Screen step may be repeated multiple times, with its Screen's content commands producing potentially different evaluation results each time.  

The order in which the content commands are evaluated in depends on their placement in the HTML. In most cases this order doesn't really matter, but in short the basic rule is that the higher and earlier in the HTML structure's hierarchy an element is, the sooner it is handled by the evaluation process. For example, if there's a content command attribute on a table cell, and another on a paragraph within the table cell, the former of these is evaluated first. And if there's a content command before the table that cell is in, that command is evaluated before either of those commands.

Should there be more than one attribute content command placed on a single element, the order in which these content commands perform their operations is defined by their priority value. The priority is a number value set for each kind of content command and the higher it is, the sooner the command gets to do its work. For example, in the image below the content commands if, content and repeat are all set on a single element.

image-20240110-143907.png

How this plays out is that if, with its priority of 1000, works first. Should its condition evaluate to false, the host element disappears and none of the other commands take effect. But in case that doesn't happen, repeat goes next, with its priority of 100, starting to multiply the host element. Last is content, with its priority of 15, that has now been multiplied along with the host element by repeat.  

The priority values of these, and all other, content commands can be found in their documentation pages.

Element logic

Besides containing content commands, HTML resources can also contain commands within logic containers called Element logic. Element logic may be bound to any HTML element that has at least one content command in it. This logic container may contain any number of commands that will be evaluated in a sequence, as if in a Step, before any of the content commands on the element. The commands in Element logic, as well as the content commands on that element, will be evaluated in their own local variable context that is terminated once the last content commands's evaluation has finished. Element logic is therefore best used to initialize variables for the content commands.

In the Template editor you can find Element logic in the same place as the content commands, just press the Logic button below the content command inputs and the container for commands appears.

image-20240112-110029.png

Similar to how content commands behave, the commands in Element logic are not evaluated if the element having the logic has been removed from the document by a prior content command evaluation.

Screen HTML

HTML resources that are being used as Screens have a couple special things to be aware of as they are parts of the Flow and their structure can affect what happens in the logic that follows. The first and most important thing to note is the submit button. Only by pressing a button of the type "submit" can the user exit the Screen and make the Flow's evaluation process continue. Therefore, at least one such button should be present on every Screen. Fortunately, all buttons are of this type by default, so adding one isn't difficult. Often Screens contain multiple buttons as each button also defines the Step following the current Screen step through the content command next, multiple buttons therefore create multiple routes for the evaluation process.

Another consideration with Screen HTML are form input elements. Every input, textarea, select and all inputs produced through content commands create a variable into the main variable context when the Screen step finishes. A variable created like this gets its name from the "name" attribute of the associated input element and the variable's value is whatever the input's value is. It is good to make sure that every such input element therefore has a unique name. This Screen-based variable creation will also overwrite values of existing variables, should any of the input elements have same names as existing variables.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.