> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/python-development-quick-start-guide/cortex-xsoar-python-development-quick-start-guide/development-tools-and-resources/cortex-xsoar-automation-scripts/add-a-table-to-the-incident-layout.md).

# Add a Table to the Incident Layout

You can enhance your incident investigation by adding an incident field that shows data in table format.

This example automation creates a field called **gridfield** that has a type **Grid (table)** with two columns named **Column1** and **Column2**.  Before saving it, delete the one empty row.&#x20;

![cortex-xsoar-automation-new-gridfield.png](/files/l8USZc20XHrw9OTQE3Zu)

1. Choose an incident layout and in the **Incident Layout Builder**, add a section for displaying the new **gridfield** field.

   ![cortex-xsoar-automation-add-new-gridfield.png](/files/tHycoLIZ7KxjEcWPZS9C)
2. Add the **gridfield** incident field to the layout.

   ![cortex-xsoar-automation-add-new-gridfield-2.png](/files/3hvEHxs6W6GFuQQDSyyp)
3. Use the basic automation template to create the following code.

   With the field and layout created, create an automation to update the rows of a grid field with a dictionary of rows and columns converted to JSON.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><h3>Note</h3><p>The column names in the dictionary are referred to by their machine names, which in this example is lower case column1 versus Column1 as displayed in the field and layout.  If the column names and order in the dictionary do not match the machine names and order of the columns in the grid field, the update is ignored.</p></div>

   The new grid dictionary, **`gridDict`**, is assigned in a dictionary with the name of the field, **`gridfield`**, as the key and converted to a JSON string by the **`json.dumps()`** Python function.

   The grid rows are updated by the **`demisto.executeCommand()`** function, setting **`customFields`** to the field values in the **`gridRows`** dictionary.

   ```programlisting
   def main():
       try:
           gridDict = {
               "column1": "This is column 1", 
               "column2": "This is column 2"
           }
           gridRows = json.dumps({ "gridfield": gridDict })
           results  = demisto.executeCommand("setIncident", {
                       'customFields': gridRows
           })
           return_results(results)
       except Exception as ex:
           demisto.error(traceback.format_exc())
           return_error("Failed updating grid field: " +
               str(ex)
           )

       if __name__ in ("__main__", "__builtin__", "builtins"):
               main()
   ```


---

# 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 dynamically by asking a question.

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

```
GET https://cortex-docs.paloaltonetworks.com/python-development-quick-start-guide/cortex-xsoar-python-development-quick-start-guide/development-tools-and-resources/cortex-xsoar-automation-scripts/add-a-table-to-the-incident-layout.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
