createFromTemplate (NotesDatabase - JavaScript)

Creates a new database from an existing database.

Defined in

NotesDatabase

Syntax

createFromTemplate(server:string, dbfile:string, inherit:boolean) : NotesDatabase

createFromTemplate(server:string, dbfile:string, inherit:boolean, maxsize:int) : NotesDatabase

Parameter Description
server The name of the server where the new database resides. Specify null or an empty string ("") to create a database on the current computer.
String dbfile The file name of the new database.
boolean inherit Specify true if you want the new database to inherit future design changes from the template; otherwise, specify false.
int maxsize The maximum size (in gigabytes) that you would like to assign to the new database. This parameter applies only to Release 4 databases or those created on a server that has not been upgraded to Release 5. Entering an integer greater than 4 generates a runtime error.
Return value Description
NotesDatabase The new database, which contains the forms, subforms, fields, views, folders, navigators, agents, and documents of the template.

Usage

If a database with the specified file name already exists, an exception is thrown.

The new database has the design elements and documents of the existing database.

If "Database file is a master template" is set in the current database, the ACL of the new database takes the following entries:
  • The current user with Manager access.
  • The server containing the database with Manager access, if the new database is on a server.
  • "-Default-" with indeterminate access. You should explicitly set the access for -Default- after creating the database.
  • Any bracketed names in the ACL of the existing database with the brackets removed; for example, "[Mary Brackets]" in the existing ACL becomes "Mary Brackets" in the new ACL. No other entries are copied from the existing ACL.

If "Database file is a master template" is not set in the current database, the ACL of the current database is copied to the new database.

If "Database file is a master template" is set in the current database and the new database is on a server, that server is set as the administration server for the new database.

Programs making remote (IIOP) calls to a server can't create or access databases on other servers. In these cases, the server parameter must correspond to the server the program is running on. There are two ways to do this:
  • Use null or an empty string ("") to indicate the current computer. This is the safer method.
  • Make sure the name of the server that the program runs on matches the name of the server parameter.

Programs running on a client can access several different servers in a single program.

Examples

This button creates a database from the discussion template.
var template:NotesDatabase = session.getDatabase(null, "discussion8.ntf", false);
if (template == null) {
	requestScope.status = "discussion8.ntf does not exist locally";
	return;
}
var newdb:NotesDatabase = template.createFromTemplate (null, "suggest", true);
newdb.setTitle("Suggestions for Giving Campaign");
newdb.grantAccess("-Default-", NotesACL.LEVEL_READER);
requestScope.status = "\"Suggestions for Giving Campagn\" created";