Skip to content

items.NewSite

Overview

Create a new instance of the "apiModel object" for the "Site" in the "Server Script".

Syntax

items.NewSite(referenceType)

Parameters

Parameter Type Required Description
referenceType string Yes Specify the site type.
"Sites": Site
"Issues": Time-limited Table
"Results": Recorded Table
"Wikis": Wiki
"DashBoard": Dashboard

Return Value

Returns the "apiModel object" of the "Site".

Usage Example 1

In the example below, a "Folder" named "Pleasanter" will be created on the top page (site ID 0).

JavaScript
let siteId = 0;
let item = items.NewSite("Sites");
item.Title = 'Pleasanter';
items.Create(siteId, item);
context.Log(item.SiteId); // Output ID of the created site

Usage Example 2

In the example below, we create a "Time-limited Table" named "Issue Management" on site ID 2. Use items.Create.

JavaScript
let siteId = 2;
let item = items.NewSite("Issues");
item.Title = 'Issue Management';
let siteSettings = {}
item.SiteSettings = $ps.JSON.stringify(siteSettings);
items.Create(siteId, item);
context.Log(item.SiteId); // Output ID of the created site

Usage Example 3

In the example below, we create a "Recorded Table" named "Customer Management" on site ID 2. Use apiModel.Create.

JavaScript
let siteId = 2;
let apiModel= items.NewSite("Results");
apiModel.Title = 'Customer Management';
let siteSettings = {}
apiModel.SiteSettings = $ps.JSON.stringify(siteSettings);
apiModel.Create(siteId);
context.Log(apiModel.SiteId); // Output ID of the created site