Introduction
The CreateTicket() MetaScript function is used to create a new record in the database for a document type or folder type.
Parameters
CreateTicket( object_type, ticket_id, field_data )
- object_type: What kind of a record you wish to create.
- ticket_id: If this is an autonumbered field, you must use null for this parameter. Otherwise, use the ID you wish to create.
- field_data: This is for information you wish to be saved with the record.For example, if you want the Request_Number saved to a same named field, you would use {Request_Number: Field( 'Request_Number' )}
Example
var result = CreateTicket("Jobs", Field( 'GR_Number' ), {"Job Name" : Field( 'Job_Name' ), "Description" : Field( 'Job_Request_Descript' ), "Customer Code" : Field( 'Customer_Code' ) });
if ( result.id !== undefined )
{
alert("A job with the same GR Number has been created.");
}
else
{
alert("Job creation failed.");
}
To use the example:
- Download the library file (see below).
- Import the form and scripts into Virtual Ticket.
- Create a new record with the form. Click the Create Ticket button to have a new record created.
Resources
Download and install a sample form illustrating this Toolbox Snippet (see below).