> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/advanced-template-logic/related-lists/additional-troubleshooting/conditional-formatting-for-color-of-cells-in-a-related-list.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
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>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
