{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1094,"path":"api-reference/server-api-reference/c_RecordToHTMLAPI.md","title":"RecordToHTML - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# RecordToHTML- Global\n\nThe RecordToHTML script include is a utility class to turn a record into HTML.\n\nThis script include is available to server-side scripts.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## RecordToHTML - RecordToHTML\\(String table, String sys\\_id, String pattern, Boolean link\\)\n\nCreates an instance of a RecordToHTML class.\n\n<table id=\"table_zdx_h3v_4t\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ntable\n\n</td><td>\n\nString\n\n</td><td>\n\nTable name of the record.\n\n</td></tr><tr><td>\n\nsys\\_id\n\n</td><td>\n\nString\n\n</td><td>\n\nSys\\_id of the record.\n\n</td></tr><tr><td>\n\npattern\n\n</td><td>\n\nString\n\n</td><td>\n\nThe 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.\n\n</td></tr><tr><td>\n\nlink\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether generate results as an HTML link.Valid values:\n\n-   true: The record information is generated as a link in an HTML tag.\n-   false: The record information is generated as text.\n\nDefault: False\n\n</td></tr></tbody>\n</table>The following example shows how to generate formatted incident record information in an HTML link.\n\n```\nvar r2html = new RecordToHTML(\"incident\", \"e8e875b0c0a80164009dc852b4d677d5\",\n\"incident: ${number}-${short_description}\");\ngs.print(r2html.toString());\n```\n\nOutput:\n\n```\n<a href=\"incident.do?sys_id=e8e875b0c0a80164009dc852b4d677d5\"><u>incident: INC0000005-CPU load high for over 10 minutes</u></a>\n\n```\n\n## RecordToHTML - setValue\\(String fieldName, String value\\)\n\nSets the specified field to the specified value.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field to change.|\n|value|String|Value to set the field to.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to generate formatted incident record information including the user name as a string.\n\n```\nvar r2html = new RecordToHTML(\"incident\",\"e8e875b0c0a80164009dc852b4d677d5\", \"incident: ${number}-${short_description} (${user})\", true);\nr2html.setValue(\"user\", gs.getUserName());\ngs.print(r2html.toString());\n```\n\nOutput:\n\n```\nincident: INC0000005-CPU load high for over 10 minutes (admin)\n```\n\n## RecordToHTML - toString\\(\\)\n\nConverts a RecordToHTML object to a string.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|HTML output of the record in the pattern set using the RecordToHTML\\(\\) constructor.|\n\nThe following example shows how to convert a RecordToHTML object to a string and display the results.\n\n```\nvar r2html = new RecordToHTML(\"incident\",\"e8e875b0c0a80164009dc852b4d677d5\", \n                          \"incident: ${number}-${short_description}\", true);\ngs.print(r2html.toString());\n```\n\nOutput:\n\n```\n<a href=\"incident.do?sys_id=e8e875b0c0a80164009dc852b4d677d5\"><u>incident: INC0000005-CPU load high for over 10 minutes</u></a>\n```\n\n"}}