Test Enterprise-Class Web CMS Scrivito Free for 30 Days
Test Scrivito Free for 30 Days
New in 1.18.0

create(attributes)

Creates a new Obj with the given attributes and assigns it to the site.

frenchPost = Scrivito.getClass("BlogPost").onSite('fr'); frenchPost.create({ title: "Salut tout le monde!" });

Params

  • attributes (Object) – The custom attributes and their values of the new CMS object.

Throws

  • ArgumentError – If a given attribute is invalid.

Returns

The created Obj.

See also

Obj.create

Example

Create an object belonging to every site:

BlogPost = Scrivito.getClass("BlogPost"); sharedObj = BlogPost.onAllSites().create({ title: "Available from all sites" }); objId = sharedObj.id(); await sharedObj.finishSaving(); console.log({ en: BlogPost.onSite('en').get(objId).get("title"), fr: BlogPost.onSite('fr').get(objId).get("title") });