# Related List Attributes

Use these attributes inside `<column>` tags to control how related list values display.

They are most useful when you want to:

* clean up labels
* format dates or numbers
* add fallback text
* hide columns conditionally
* build more readable output for end users

{% hint style="info" %}
These examples also work when a named query runs before the related list.
{% endhint %}

### Quick picks

Start with these first:

* `format-number` for currency, phone numbers, and other numeric output
* `format-date` for Salesforce date and datetime fields
* `prefix` / `postfix` for labels and units
* `substitute` for exact value swaps
* `replaceall` for partial text swaps
* `render` for advanced conditional output

### Replace or clean text

#### `substitute`

Replaces the **entire value** when it matches exactly.

Use it when the stored value is correct, but not user-friendly.

```xml
<column substitute="RED,BLUE,GREEN,YELLOW">Color__c</column>
```

Examples:

* `RED` → `BLUE`
* `RED FIRETRUCK` → `RED FIRETRUCK`

#### `replaceall`

Replaces only the matching part of a value.

Use it when the field contains longer text.

```xml
<column replaceall="RED,BLUE,GREEN,YELLOW">Description__c</column>
```

Examples:

* `RED` → `BLUE`
* `RED FIRETRUCK` → `BLUE FIRETRUCK`
* `PINK FIRETRUCK` → `PINK FIRETRUCK`

#### `breakeverynchars`

Forces long strings to break more cleanly.

This helps with URLs, IDs, and other long text that stretches a table.

```xml
<column breakeverynchars="2">Name</column>
```

Example:

* `Opportunity Name` → `Op po rt un it y Na me`

### Add text before or after values

#### `prefix`

Adds text before a value.

It only appears when the field has a value.

```xml
<column prefix="$">Amount</column>
```

Example:

* `1250` → `$1250`

#### `postfix`

Adds text after a value.

It only appears when the field has a value.

```xml
<column postfix=" units">Quantity</column>
```

Example:

* `5` → `5 units`

<details>

<summary>Null and "always show" variants</summary>

**`nullprefix`**

Adds text before the output only when the field is null.

```xml
<column nullprefix="No value provided">Description</column>
```

**`nullpostfix`**

Adds text after the output only when the field is null.

```xml
<column nullpostfix="Not available">Description</column>
```

**`allprefix`**

Adds text whether the field has a value or is null.

This saves you from combining `prefix` and `nullprefix`.

```xml
<column allprefix="$">Amount</column>
```

**`allpostfix`**

Adds text whether the field has a value or is null.

This saves you from combining `postfix` and `nullpostfix`.

```xml
<column allpostfix="%">Discount__c</column>
```

</details>

### Format output

#### `format-number`

Formats numeric values using a pattern.

Use it for currency, separators, decimals, or phone-style output.

```xml
<column format-number="#,###.##">Amount</column>
<column format-number="#.###,##">Amount</column>
<column prefix="$" format-number="-#,###.##">Amount</column>
<column postfix="€" format-number="-#,###.##">Amount</column>
<column format-number="+### ###.###.####">Phone__c</column>
<column format-number="###-###-####">Phone__c</column>
<column format-number="(###) ###-####">Phone__c</column>
```

Examples:

* `1234567891234` → `12,345,678,912.34`
* `1234567891234` → `12.345.678.912,34`
* `1234567891234` with `prefix="$"` → `$-12,345,678,912.34`
* `1234567891` → `123-456-7891`
* `1234567891` → `(123) 456-7891`

#### `format-date`

Formats Salesforce date and datetime fields with a Java date pattern.

```xml
<column format-date="M/d/yyyy">CloseDate</column>
<column format-date="MMMM dd, yyyy">CloseDate</column>
<column format-date="EEE MMM d, yyyy">CloseDate</column>
<column format-date="M/d/yyyy hh:mm">CreatedDate</column>
<column format-date="MMM d, yyyy HH24:mm:ss">CreatedDate</column>
<column format-date="MMMM dd, yyyy h:mm TZ:Central Standard Time (America/Chicago)">CreatedDate</column>
<column format-date="dd MMMM, yy hh:mm a">CreatedDate</column>
```

If the input is `January 3, 2026 12:00 PM EST`, the output can be:

* `1/3/2026`
* `January 03, 2026`
* `Sat Jan 3, 2026`
* `1/3/2026 12:00`
* `Jan 3, 2026 12:00:00`
* `January 03, 2026 11:00 CST`
* `03 January, 26 12:00 PM`

#### `type`

Controls how S-Docs renders the field value.

```xml
<column type="rtf">Rich_Text__c</column>
<column type="text">Rich_Text__c</column>
<column type="checkbox">Approved__c</column>
<column type="radio">Selected__c</column>
```

Common options:

* `type="rtf"` keeps rich text formatting
* `type="text"` strips HTML tags
* `type="checkbox"` shows checkbox images for true/false style values
* `type="radio"` shows radio button images for yes/no style values

### Combine values from two columns

#### `mergenext`

Merges the current cell with the cell to its right.

This is useful for first name + last name, city + state, or label + value pairs.

```xml
<column mergenext="true" postfix=" ">FirstName</column>
<column>LastName</column>
```

Example:

* `Scuba` + `Steve` → `Scuba Steve`

### Show or hide output conditionally

#### `showcolumn`

Shows or hides a column based on a condition.

```xml
<column showcolumn="{{!BaseObject.FieldName}} == 'Expected Value'">Field__c</column>
```

Use this when the same template should show different columns for different records.

{% hint style="warning" %}
`showcolumn` removes the body column only. If you have a table header, remove that header separately.
{% endhint %}

#### `render`

Outputs different text based on other values from the same row.

This is the most flexible attribute on this page.

```xml
<column render="RECORD.Title == null,No Title Available,RECORD.Name"></column>
```

You can also return formatted rich text:

```xml
<column type="rtf" render="RECORD.isclosed == 'false', lt#span style='color:red;'gt#Falselt#/spangt#, lt#span style='color:green;'gt#Truelt#/spangt#"></column>
```

Rules:

* Use `RECORD.FieldName` to reference fields from the current row
* Include any referenced fields in the SOQL query
* Leave the body of the `<column></column>` tag empty when using `render`
* Escape tag brackets inside the output with `lt#` and `gt#`

{% hint style="info" %}
`render` is supported in direct SOQL related lists. Use it inside blocks with `<soql>...</soql>`.
{% endhint %}

### Example: several attributes together

```xml
<table class="table1">
  <thead>
    <tr>
      <th>Name</th>
      <th>Close Date</th>
      <th>Amount</th>
      <th>Status</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>
    SELECT Name, CloseDate, Amount, IsClosed
    FROM Opportunity
    WHERE Amount != null
    ORDER BY CloseDate DESC
  </soql>
  <column>Name</column>
  <column format-date="MMM d, yyyy">CloseDate</column>
  <column prefix="$" format-number="#,###.00">Amount</column>
  <column render="RECORD.IsClosed == true,Closed,Open"></column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
```

### Choosing the right attribute

Use:

* `substitute` for exact matches
* `replaceall` for partial matches
* `prefix` / `postfix` for simple labels
* `format-number` and `format-date` for display formatting
* `showcolumn` to hide whole columns
* `render` when the output depends on row-level logic


---

# 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/developer-hub/template-configuration-and-styling/related-list-references/related-list-attributes.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.
