#ADD
Syntax
Parameters
- Content Type - Which Content Type to add information to.
- Folder ID - The ID of the folder which will hold the new Content Record.
- User - Which account will be credited for adding the new content.
- Comment - Additional text which does not effect functionality.
Description
Creates a content record in webCOMAND of the specified Content Type in the specified folder. The record will appear to have been created by the specified user when accessed in webCOMAND. The comment will be recorded in the content log.
The value for each field in the content record is set using the #ASSIGN, #NEW or #APPEND statements inside the #ADD block. A content record field is set by assigning a value to a variable with a name that corresponds to the field identifier.
Fields that contain a single reference multiple references to other content records may also be set with #ASSIGN or #NEW statements inside the #ADD block. Those fields are also set by assigning a value to a variable with a name that corresponds to the field identifier. For a single reference field, the value should be the ID number that corresponds to the content record to be referenced. For multiple references, the value should be a comma separated list of ID numbers that correspond to the content records to be referenced.
Fields that contain multiple references to other content records may be set in a similar way, except the value assigned to the variable must be a comma separated list of IDs.
While inside the #ADD block, $ID, $OID and $UUID will be equal to the corresponding values of the new record that will be created once the #ENDADD is encountered. This is useful when a script will need to know the ID of the content record just added (see second example).
This statement does not produce output.
Example 1
#ADD(ContactInfo,2,'webcomand','Web Site Form')
#ASSIGN($FirstName,$GetFirstName)
#ASSIGN($LastName,$GetLastName)
#ENDADD
Result
The new ContactInfo record will be added.Analysis
In the previous example, the values for variables $GetFirstName and $GetLastName were added to the "FirstName" and "LastName" fields of the "ContactInfo" Content Type, to be displayed under the Folder with an ID of 2, by User "webcomand" with a comment attached saying "Web Site Form".Example 2
#ADD(Contact,6,'webcomand','Web Site Form')
#ASSIGN($FirstName,'John')
#ASSIGN($LastName,'Smith')
#ASSIGN($NewContactID,283)
#ENDADD
#CONTEXT(Contact,ID=$NewContactID)
<h1>New Contact</h1>
ID: $ID<br />
Name: $FirstName $LastName<br />
#ENDCONTEXT
Result
<h1>New Contact</h1>
ID: 53<br />
Name: John Smith<br />
Analysis
A new Contact record is created in the folder with an ID of 7. The record will be logged as being created by the user "webcomand" with a comment of "Web Site Form". The FirstName field is set to "John" and the LastName field is set to "Smith". The ID of the new record is stored in the variable $NewContactID, which is subsequently used to retrieve the new record in a #CONTEXT statement, which then displays the new contact information, as it is stored in webCOMAND. In this example, the new record was assigned the ID 53.