OpenWGA 7.10 - TMLScript reference

HDBModel
Method :

createContent(hdbCreateParams)
createContent(contentClass [, refDocument] [, customParam])
createContent(tmlForm)

On object HDBModel
Usage Creates a new HDBModel content
Description

The method knows three different variants, depending on what input should be given to the creation operation.

The full variant 1 takes a HDBModelParams object which can be created via HDBModel.newCreateContentParams(). This object collects all parameters that a creation operation may be given.

Variant 2 is a convenience version where a new content of a given content class should just be created below some reference document in TMLScript.

Variant 3 can be used instead of default action $store if a content should be created based on the data of a WebTML form. The reference document here is taken from the target context of the form. The content class is taken from the contentclass attribute of the form (The operation will fail if none is given). Form fields and uploaded attachments are stored to the new content document.

Parameters

Variant 1:

hdbCreateParams (HDBModelParams):

All parameters for the create operation. The refDocument property is taken as reference document for the create operation, like described for variant 2.

Variant 2:

contentClass (String):

The content class of the content to create.

refDocument (WGAPI object WGContent | TMLContext | Context expression) (optional):

The reference document for the create operation. May be some immediate parent content or storage of the content to create (with no other contents in-between). May be null if the content to create has no parent content.

If refDocument is not present the current context is taken as parent.

customParam (any object, optional):

A custom parameter object for the create operation, which may be processed by event scripts.

Variant 3:

tmlForm (TMLForm):

A WebTML form holding all neccessary data for the create operation.


Writable False
Return value The created content (WGAPI object WGContent)
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Examples

Creating HDBModel content, giving content class, reference document (the current context) and a custom param object in the form of a JavaScript object:

HDBModel.createContent("category", content(),
  {
    title: "Public",
    allowed: true,
    creator: "ow"
   }
);