Professional Documents
Culture Documents
Vancouver - Api - Reference - 1-12-2024 - 1
Vancouver - Api - Reference - 1-12-2024 - 1
Vancouver API
Reference
Last updated: January 12, 2024
Company Headquarters
2225 Lawson Lane
Santa Clara, CA 95054
United States
(408)501-8550
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
This API is a component used with the Document API to generate a PDF.
Build a Table object using the methods in this class. You can use these
additional classes to add cells, paragraphs, and styles to your table:
Cell API
Create a cell using the Cell API. Then, add the cell to your table using
one of these methods:
• Table.addCell()
• Table.addCellWithStyle()
• Table.addHeaderCell()
• Table.addImageCell()
• Table.addParagraphCell()
• Table.addTextCell()
Paragraph API
Style API
Set styles, colors, and borders using the Style API. Add the styles to the
table using one of these methods:
• Table.setDefaultStyle()
• Table.setHeaderStyle()
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
You can then apply the Table object to a PDF document using the
following class and method.
Document API
Instantiates a new Table object with text direction, column width, and
layout settings.
Parameters
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Default: false
Example
Parameters
Returns
Type Description
None
Example
This example shows how to create a Table object from the incident table
and add a Number and a Short Description cell to each row.
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
// Query Incident
var gr = new GlideRecord("incident");
gr.query();
table.setHeaderStyle(headerStyle);
hdrCell1.addParagraph(nParagraph);
hdrCell2.addParagraph(sParagraph);
table.addHeaderCell(hdrCell1);
table.addHeaderCell(hdrCell2);
var row = 0;
while(gr.next()) {
var numCell = new sn_pdfgeneratorutils.Cell;
var sdCell = new sn_pdfgeneratorutils.Cell;
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
numCell.addParagraph(numberParagraph);
sdCell.addParagraph(sdParagraph);
if (row % 2 == 1) {
table.setDefaultbackGroundColor(greyColor);
} else {
table.setDefaultbackGroundColor(whiteColor);
}
table.addCell(numCell);
table.addCell(sdCell);
row = row + 1;
document.addTable(table);
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
Parameters
Returns
Type Description
None
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Example
This example shows how to apply a style to a specified Cell object and
save the document as an attachment to a record.
// Query Incident
var gr = new GlideRecord("incident");
gr.query();
hdrCell1.addParagraph(nParagraph);
hdrCell2.addParagraph(sParagraph);
table.addHeaderCell(hdrCell1);
table.addHeaderCell(hdrCell2);
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
var row = 0;
while(gr.next()) {
var numCell = new sn_pdfgeneratorutils.Cell;
var sdCell = new sn_pdfgeneratorutils.Cell;
numCell.addParagraph(numberParagraph);
sdCell.addParagraph(sdParagraph);
if (row % 2 == 1) {
table.setDefaultbackGroundColor(greyColor);
} else {
table.setDefaultbackGroundColor(whiteColor);
}
table.addCellWithStyle(numCell, cellStyle);
table.addCell(sdCell);
row = row + 1;
document.addTable(table);
document.saveAsAttachment("incident", "sys_id", "filename.
pdf");
Parameters
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Returns
Type Description
None
Example
This example shows how to add a header cell to a table that contains
a Paragraph object. For more information on Paragraph objects, see the
Paragraph API.
// Query Incident
var gr = new GlideRecord("incident");
gr.query();
table.setHeaderStyle(headerStyle);
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
hdrCell1.addParagraph(nParagraph);
hdrCell2.addParagraph(sParagraph);
table.addHeaderCell(hdrCell1);
table.addHeaderCell(hdrCell2);
var row = 0;
while(gr.next()) {
var numCell = new sn_pdfgeneratorutils.Cell;
var sdCell = new sn_pdfgeneratorutils.Cell;
numCell.addParagraph(numberParagraph);
sdCell.addParagraph(sdParagraph);
if (row % 2 == 1) {
table.setDefaultbackGroundColor(greyColor);
} else {
table.setDefaultbackGroundColor(whiteColor);
}
table.addCell(numCell);
table.addCell(sdCell);
row = row + 1;
document.addTable(table);
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
Returns
Type Description
None
Example
This example shows how to create a table with two image cells and
attach the document to a record.
table.addImageCell(icon);
table.addImageCell(picture);
document.addTable(table);
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
Table – addParagraphCell(Paragraph p)
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
Paragrap
p Paragraph object to add to the cell.
h
Returns
Type Description
None
Example
This example shows how to create a table with a single cell containing
paragraph content.
table.addParagraphCell(paragraph);
document.addTable(table);
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
Returns
Type Description
None
Example
This example shows how to create a table with a single cell containing a
string.
document.addTable(table);
document.saveAsAttachment("incident", "record_sys_id", "fi
lename.pdf");
Table – complete()
Indicates that all the intended content has been added to a large table.
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
None
Returns
Type Description
None
Example
// Query Incident
var gr = new GlideRecord("incident");
gr.query();
table.setHeaderStyle(headerStyle);
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
hdrCell1.addParagraph(numberParagraph);
hdrCell2.addParagraph(descParagraph);
hdrCell3.addParagraph(stateParagraph);
hdrCell4.addParagraph(assignedParagraph);
table.addHeaderCell(hdrCell1);
table.addHeaderCell(hdrCell2);
table.addHeaderCell(hdrCell3);
table.addHeaderCell(hdrCell4);
var row = 0;
while(gr.next()) {
var numCell = new sn_pdfgeneratorutils.Cell;
var sdCell = new sn_pdfgeneratorutils.Cell;
var stateCell = new sn_pdfgeneratorutils.Cell;
var assignedCell = new sn_pdfgeneratorutils.Cell;
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
numCell.addParagraph(numberParagraph);
sdCell.addParagraph(sdParagraph);
stateCell.addParagraph(stateParagraph);
assignedCell.addParagraph(assignedParagraph);
if (row % 2 == 1) {
table.setDefaultbackGroundColor(greyColor);
} else {
table.setDefaultbackGroundColor(whiteColor);
}
table.addCell(numCell);
table.addCell(sdCell);
table.addCell(stateCell);
table.addCell(assignedCell);
row = row + 1;
document.addTable(table);
table.addTextCell("A cell added later");
table.flush();
table.complete();
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
Parameters
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Default: false
Returns
Type Description
None
Example
This example shows how to prevent splitting a row across two pages.
table.donotSplitRowOnPageBreak(true);
document.addTable(table);
document.saveAsAttachment("incident", "record_sys_id", "fi
lename.pdf");
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Table – flush()
Use with the Table.complete() method to indicate that you have added
all additional content to the table. This method only applies when the
largeTable parameter in the constructor is set to true.
Parameters
None
Returns
Type Description
None
Example
This example shows how to add a text cell to a table that is already
added to a document.
// Query Incident
var gr = new GlideRecord("incident");
gr.query();
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
table.setHeaderStyle(headerStyle);
hdrCell1.addParagraph(numberParagraph);
hdrCell2.addParagraph(descParagraph);
hdrCell3.addParagraph(stateParagraph);
hdrCell4.addParagraph(assignedParagraph);
table.addHeaderCell(hdrCell1);
table.addHeaderCell(hdrCell2);
table.addHeaderCell(hdrCell3);
table.addHeaderCell(hdrCell4);
var row = 0;
while(gr.next()) {
var numCell = new sn_pdfgeneratorutils.Cell;
var sdCell = new sn_pdfgeneratorutils.Cell;
var stateCell = new sn_pdfgeneratorutils.Cell;
var assignedCell = new sn_pdfgeneratorutils.Cell;
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
ph(gr.number);
var sdParagraph = new sn_pdfgeneratorutils.Paragraph(g
r.short_description);
var stateParagraph = new sn_pdfgeneratorutils.Paragrap
h(gr.state);
var assignedParagraph = new sn_pdfgeneratorutils.Parag
raph(gr.assigned_to);
numCell.addParagraph(numberParagraph);
sdCell.addParagraph(sdParagraph);
stateCell.addParagraph(stateParagraph);
assignedCell.addParagraph(assignedParagraph);
if (row % 2 == 1) {
table.setDefaultbackGroundColor(greyColor);
} else {
table.setDefaultbackGroundColor(whiteColor);
}
table.addCell(numCell);
table.addCell(sdCell);
table.addCell(stateCell);
table.addCell(assignedCell);
row = row + 1;
document.addTable(table);
table.addTextCell("A cell added later");
table.flush();
table.complete();
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
Table – getDefaultStyle()
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
None
Returns
Type Description
Example
This example shows how to set and then return the default style.
style.setItalic();
table.setDefaultStyle(style);
gs.info(defaultStyle);
Table – getHeaderStyle()
Parameters
None
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Returns
Type Description
Example
This example shows how to set and return the table's header style.
table.setHeaderStyle(headerStyle);
table.addHeaderCell(hdrCell1);
table.addHeaderCell(hdrCell2);
gs.info(styleObject);
Sets a border of designated width around the outer edges of the table.
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
Returns
Type Description
None
Example
This example shows how to create a table with two-pixel border and
attach the table to a record.
document.addTable(table);
"document.saveAsAttachment("incident", "<record_sys_id>"
, "filename.pdf");
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
Returns
Type Description
None
Example
This example shows how to set the default background color for the
table.
table.setDefaultbackGroundColor(color);
Parameters
defaultStyl
Style Default style to apply to the table.
e
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Returns
Type Description
None
Example
style.setItalic();
table.setDefaultStyle(style);
gs.info(defaultStyle);
Parameters
pageNum
Number Number of the page to add the table to.
ber
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Returns
Type Description
None
Example
This example shows how to reposition the table into the bottom left
corner of the page.
document.addTable(table);
"document.saveAsAttachment("incident", "<record_sys_id>"
, "filename.pdf");
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
headerStyl
Style Style object to apply to the table's header.
e
Returns
Type Description
None
Example
This example shows how to set and return the table's header style.
table.setHeaderStyle(headerStyle);
table.addHeaderCell(hdrCell1);
table.addHeaderCell(hdrCell2);
gs.info(styleObject);
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
Returns
Type Description
None
Example
This example shows how to create a small table aligned in the center of
the page.
document.addTable(table);
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
Parameters
Returns
Type Description
None
Example
This example shows how to set a margin for the entire table.
document.addTable(table);
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
Returns
Type Description
None
Example
This example shows how to set a margin for the bottom of the page to
three points.
// Query Incident
var gr = new GlideRecord("incident");
gr.query();
table.setHeaderStyle(headerStyle);
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
hdrCell1.addParagraph(nParagraph);
hdrCell2.addParagraph(sParagraph);
table.addHeaderCell(hdrCell1);
table.addHeaderCell(hdrCell2);
var row = 0;
while(gr.next()) {
var numCell = new sn_pdfgeneratorutils.Cell;
var sdCell = new sn_pdfgeneratorutils.Cell;
numCell.addParagraph(numberParagraph);
sdCell.addParagraph(sdParagraph);
if (row % 2 == 1) {
table.setDefaultbackGroundColor(greyColor);
} else {
table.setDefaultbackGroundColor(whiteColor);
}
table.addCell(numCell);
table.addCell(sdCell);
row = row + 1;
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
document.addTable(table);
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
Parameters
Returns
Type Description
None
Example
This example shows how to set a margin for the left side of the page.
document.addTable(table);
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
Returns
Type Description
None
Example
This example shows how to set a margin for the left side of the page.
document.addTable(table);
"document.saveAsAttachment("incident", "<record_sys_id>"
, "filename.pdf");
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Parameters
Returns
Type Description
None
Example
This example shows how to set a margin at the top of the page.
document.addTable(table);
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
Parameters
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Returns
Type Description
None
Example
This example shows how to create a table 90 points wide and attach the
document to a record.
document.addTable(table);
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
Table – useAllAvailableWidth()
Expands the table to use the entire width available on the page.
Parameters
None
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.
Vancouver API Reference
Returns
Type Description
None
Example
This example shows how to create a table that expands to the available
width on the page.
document.addTable(table);
document.saveAsAttachment("incident", "<record_sys_id>",
"filename.pdf");
ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the
United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are
associated.