# Conditional Formatting for Color of Cells in a Related List

There may be some situations where you may want to color the cells in your related list. This can be done by using bgcolor='color'. While this is simple enough, a more complex case arises when you want the color of the cell to change based on conditional logic. Below is an example of this.

{% hint style="info" %}
An important note to this is that most of the <> symbols will need to be escaped (#lt, #gt) in order for this to work and be properly read.
{% endhint %}

```
<table>
<thead>
<tr>
<th>id</th>
<th>amount</th>
<th>amountrender</th>
</tr>
</thead>
<tbody><!--{{!
<lineitemsSOQL>
<class>none</class>
<soql> select id, amount from opportunity</soql>
<column prefix="<tr><td bgcolor='yellow'>" postfix="</td>">amount</column>
<column type="rtf" render="RECORD.amount >= 350000, lt#td bgcolor='blue' gt#RECORD.amount lt#/tdgt#,lt#td bgcolor='green'gt#RECORD.amount lt#/tdgt#"></column>
<column prefix="<td>" postfix="</td></tr>">amount</column>
</lineitemsSOQL>
}}-->
</tbody>
</table>
```

This can also be done with font color instead of background cell color:

```
<table>
<thead>
<tr>
<th>id</th>
<th>amountrender</th>
<th>amount</th>
</tr>
</thead>
<tbody><!--{{!
<lineitemsSOQL>
<class>none</class>
<soql> select id, amount from opportunity</soql>
<column prefix="<tr><td bgcolor='yellow'>" postfix="</td>">id</column>
<column type="rtf" render="RECORD.amount >= 350000, lt#td style='color:#0000FF' gt#RECORD.amount lt#/tdgt#,lt#td style='color:#FF0000' gt#RECORD.amount lt#/tdgt#"></column>
<column prefix="<td>" postfix="</td></tr>">amount</column>
</lineitemsSOQL>
}}-->
</tbody>
</table>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/sdocs/advanced-template-logic/related-lists/additional-troubleshooting/conditional-formatting-for-color-of-cells-in-a-related-list.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
