Formula - XHTML
Use a Formula - XHTML column to display record values within HTML markup. Place <% expression %> in the text of an element or in an attribute value. TeamDesk evaluates the expression and encodes the result for HTML. Write tag and attribute names directly in the markup.
A single numeric, date, time, or timestamp column reference uses the column’s display format. For example, <% [Expiry Date] %> displays the date as configured for that column. If a calculation returns one of these types, specify the format explicitly, as in <% Format([Expiry Date] + 1d, "d") %>.
Optional Content
A placeholder that evaluates to null contributes an empty string. The surrounding markup still appears. To omit an element together with its contents, enclose it in <%? condition %> and <%?%>. TeamDesk includes the element only when the condition is true.
For example, this formula always shows the contact’s name. It includes the phone number and its label only when the contact has a mobile number.
<p><% [Name] %></p>
<%? not IsNull([Mobile Phone]) %>
<p>Mobile: <% [Mobile Phone] %></p>
<%?%> When you open an older XHTML formula that relied on a missing value hiding the entire result, the editor wraps the formula in a condition that checks the relevant placeholders for null. This preserves the original output. To hide only an optional element, move the condition around that element.
Coloring the Status

Color a Status value green if it is "Completed", red if it is "Overdue", otherwise black.
To do this, add a new Formula - XHTML column and name it "Status(Colored)". This column can be added to a Table View instead of the existing "Status" text column, which can be used only for record editing. When the Formula - XHTML column is created, you can enter the following formula:
<font color="<%Case([Status],"Completed","#339900","Overdue","#ff3333","")%>"><% [Status] %></font> Contact Name as Email Link

Decorate contact names as e-mail links.
Create a "Contact Person" Formula-XHTML column, where the existing "Name" column is associated with a corresponding e-mail listed in the E-mail column.
Enter the following formula:
<a href="<% "mailto:" & [E-mail] %>"><% [Name] %></a> Coloring Numeric Values

Color a value red if it is less than 100.
Create the "Value (Colored)" Formula-XHTML column, where the values should be colored.
Enter the following formula:
<span style="<% If([Value] < 100, "color:red", "") %>">
<% [Value] %>
</span> Highlighting Date Background

Highlight the background of an Expiry Date value in red if it is less than today+60 days and in yellow if a value is less than today+180 days.
Create the "Colored Date" Formula-XHTML column, where the "Expiry Date" column value background should be highlighted.
Enter the following formula:
<span style="background-color:<%If([Expiry Date]<Today()+60d,"red",[Expiry Date]<Today()+180d,"yellow","")%>"><% [Expiry Date] %></span> Changing the Font Size

Increase/decrease the font size.
The Formula XHTML keeps the following formula:
<span style="font-size:300%"><%[Test Column]%></span> You can specify the percentage value you need and write a corresponding column name instead of "Test Column".
Markup Restrictions
- Markup will be displayed as text in:
- Dropdown lists, as dropdowns do not support markup;
- Calendar views and Lookup columns with "Display As Link" options checked, as a very limited set of tags can be displayed inside of a link;
- Documents as the Word file format has no connection to HTML.
-
Some tags are disabled to avoid interference with the rest of the page:
<html>, <head>, <script>, <noscript>, <title>, <meta>, <link>, <base>, <style>, <body>, <form>, <input>, <isindex>, <textarea>, <select>, <optgroup>, <option>, <fieldset>, <legend>.<button>tag is allowed only when its type attribute is set to "button". -
All allowed tags require a closing tag, even if it is not required by HTML. For example, in HTML you can write:
<p>First paragraph <p>Second paragraph -
In formula code, you should close the
</p>tag before opening a new<p>tag:<p>First paragraph</p> <p>Second paragraph</p> -
Tags that cannot have inner content, such as
<img>,<br>,<hr>, and<param>, should be self-closed, e.g., written as<br/>or<img src="image.png"/>.