---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# RecordToHTML - Global

# RecordToHTML - Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The RecordToHTML script include is a utility class to turn a record into HTML.

This script include is available to server-side scripts.

## RecordToHTML - RecordToHTML(String table, String sys_id, String pattern, Boolean
link) {#ariaid-title2}

Creates an instance of a RecordToHTML class.
{#r_RTH-RecordToHTML_S_S_S_B__table_zdx_h3v_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| table | String | Table name of the record. |
| sys_id | String | Sys_id of the record. |
| pattern | String | The pattern of the string to generate. The pattern can include ${} template literals to provide the content of existing field values. For example, the pattern "${number}" provides the number for the selected record. |
| link | Boolean | Flag that indicates whether generate results as an HTML link. Valid values: * true: The record information is generated as a link in an HTML tag. * false: The record information is generated as text. {#r_RTH-RecordToHTML_S_S_S_B__ul_t3q_zcc_rwb} Default: False |
[Table 1. Parameters]

{#r_RTH-RecordToHTML_S_S_S_B__table_zdx_h3v_4t}  
The following example shows how to generate formatted incident record information in an HTML link.

    var r2html = new RecordToHTML("incident", "e8e875b0c0a80164009dc852b4d677d5",
    "incident: ${number}-${short_description}");
    gs.print(r2html.toString());

Output:

    <a href="incident.do?sys_id=e8e875b0c0a80164009dc852b4d677d5"><u>incident: INC0000005-CPU load high for over 10 minutes</u></a>

## RecordToHTML - setValue(String fieldName, String value) {#ariaid-title3}

Sets the specified field to the specified value.
{#r_RTH-setValue_S_S__table_uh3_chv_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field to change. |
| value | String | Value to set the field to. |
[Table 2. Parameters]

{#r_RTH-setValue_S_S__table_uh3_chv_4t} {#r_RTH-setValue_S_S__table_vh3_chv_4t__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 3. Returns]

{#r_RTH-setValue_S_S__table_vh3_chv_4t}  
The following example shows how to generate formatted incident record information including the user name as a string.

    var r2html = new RecordToHTML("incident","e8e875b0c0a80164009dc852b4d677d5", "incident: ${number}-${short_description} (${user})", true);
    r2html.setValue("user", gs.getUserName());
    gs.print(r2html.toString());

Output:

    incident: INC0000005-CPU load high for over 10 minutes (admin)

## RecordToHTML - toString() {#ariaid-title4}

Converts a RecordToHTML object to a string.
{#r_RTH-toString__table_gtj_phv_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 4. Parameters]

{#r_RTH-toString__table_gtj_phv_4t} {#r_RTH-toString__table_htj_phv_4t__entry__2}

| Type | Description |
|-|-|
| String | HTML output of the record in the pattern set using the RecordToHTML() constructor. |
[Table 5. Returns]

{#r_RTH-toString__table_htj_phv_4t}  
The following example shows how to convert a RecordToHTML object to a string and display the results.

    var r2html = new RecordToHTML("incident","e8e875b0c0a80164009dc852b4d677d5", 
                              "incident: ${number}-${short_description}", true);
    gs.print(r2html.toString());

Output:

    <a href="incident.do?sys_id=e8e875b0c0a80164009dc852b4d677d5"><u>incident: INC0000005-CPU load high for over 10 minutes</u></a>


