Neolane - JavaScript API - v6.1.0

Unknown
add
Adds a new entity to the collection.
add ( [ index ], xml )
Parameters
index
The entity will be added at this index point. If this argument is not specified, the entity will be appended to the end of the list.
xml
The entity to insert in XML form.
Return value
The element created.
Remarks
The following example shows two different ways to add a new element to a collection. The first solution passes the full definition of the element to the add() method, whereas the second one passes and empty <attachment/> element then assigns the attributes in the normal way.
var delivery = nms.delivery.load("12435")

delivery.attachment.add(
  <attachment compressMode="print" filterActive="false" label="First File"
              nameScriptActive="false" type="normal" upload="false">
    <name&gt;file1.txt&lt;/name>
  </attachment>)

var attach = delivery.attachment.add(<attachment/>)
attach.label            = "Second File"
attach.name             = "file2.txt"
attach.compressMode     = "print"
attach.type             = "normal"
attach.filterActive     = false
attach.nameScriptActive = false
attach.upload           = false

delivery.save()

The two solutions are equivalent, but the second one enables you to use the JavaScript types corresponding to attribute types whereas the first one only supports strings.

Features
Method of class: EntityCollection
Available in:
  • Content management
  • Delivery properties
  • Typology rule
  • JSSP
  • SOAP Method
  • WebApp
  • Workflow

Table of contents

previous page start next page