Class Ticket
Class for representing an SuperOffice Service Ticket.
Syntax
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
Constructors
Ticket()
Class for representing an SuperOffice Service Ticket.
Declaration
Ticket
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
Methods
buildEmailSubject()
returns a String composed by the Mail tag, the ticketId and the title of the ticket
Declaration
String buildEmailSubject()
Returns
Type | Description |
---|---|
String | A String composed by the Mail tag, the ticketId and the title of the ticket. |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
checkEscalating(Integer)
This function does a check according to the ticket's priority and the input action. The effect of calling this function might be that the escalation stops, restarts or continues.
Declaration
Void checkEscalating(Integer action)
Parameters
Type | Name | Description |
---|---|---|
Integer | action | As an Integer. |
Returns
Type | Description |
---|---|
Remarks
Possible values:
- ActionRead = 0
- ActionChangedOwner = 1
- ActionNewInfo = 2
- ActionClosed = 3
- ActionChangedPriority = 4
- ActionNew = 5
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
delegate()
Delegates a ticket to a user according to the rules on the category.
For this function to take effect, you have to callTicket.save()
.
Declaration
delegate()
Returns
Type | Description |
---|---|
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
delegate(Integer)
Delegates a ticket to a user according to the rules on the category. You can optionally specify a user ID not to delegate to.
For this function to take effect, you have to callTicket.save()
.
Declaration
delegate(Integer notUser)
Parameters
Type | Name | Description |
---|---|---|
Integer | notUser | The ID of a user you do not want to delegate to. |
Returns
Type | Description |
---|---|
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
getInvolvedOnly()
Returns a comma-separated list of the email-addresses of all customers that is not a connected customer to this ticket, but who has received a message on this ticket.
Declaration
String getInvolvedOnly()
Returns
Type | Description |
---|---|
String | A comma-separated list of email-addresses. |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
getMailFrom()
This function determines and returns the most appropriate from-address, when sending a mail-message on a ticket.
Declaration
String getMailFrom()
Returns
Type | Description |
---|---|
String | The most appropriate from-address specified on with address, the ticket has arrived on, the category, etc. |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
getOwnerEmail()
This function returns the owner of the ticket printed as "Name" <email-addr>.
Declaration
String getOwnerEmail()
Returns
Type | Description |
---|---|
String | The owners name and email-address. |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
getOwnerSms()
This function returns the cellphone number of the owner of the ticket
Declaration
String getOwnerSms()
Returns
Type | Description |
---|---|
String | The cellphone number of the owner of the ticket as a String. |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
getValue(String)
Gets the value of given column name as a String
Declaration
String getValue(String colName)
Parameters
Type | Name | Description |
---|---|---|
String | colName | The name of the wanted column. |
Returns
Type | Description |
---|---|
String | Returns a string representation of the wanted value. |
Remarks
Possible values:
- id
- title
- category: the ID
- ownedBy: (owned_by), the ID of the user who owns the ticket
- slevel: the security level of the ticket, 1 is internal, 2 is external
- priority: the id
- status: 1 = active, 2 = closed, 3 = postponed, 4 = deleted, 5 = composed
- ticketStatus
- custId: the ID of the primary customer
- ticket_type/ticketType: the ID of the request type
- createdBy: the ID of the user who posted the ticket, 1 if the ticket is posted into the system
- author
- activate: the datetime when the ticket was activated
- createdAt: (created_at), the datetime when the ticket was created
- closedAt: (closed_at), the datetime when the ticket was closed
- repliedAt: (replied_at), the datetime when the ticket first was replied at
- origCategory: the original category
- origPriority: the original priority
- isInEscalation
- displayFilter
- filterId
- filterAddress
- readStatus
- deadline
- readByOwner
- firstReadByUser
- firstReadByOwner
- saleId: ID of connected Sale
- projectId: ID of connected Project
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
load(Integer)
Load ticket with given id into this object, return true if successful, false otherwise.
Declaration
Bool load(Integer id)
Parameters
Type | Name | Description |
---|---|---|
Integer | id |
Returns
Type | Description |
---|---|
Bool |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
log(String)
Writes a message to the ticket log. Used for logging changes and events on a ticket
Declaration
log(String message)
Parameters
Type | Name | Description |
---|---|---|
String | message | The message to log. |
Returns
Type | Description |
---|---|
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
log(String,String)
Writes a message to the ticket log. Used for logging changes and events on a ticket
Declaration
log(String who, String message)
Parameters
Type | Name | Description |
---|---|---|
String | who | The name of the user that made the change to log |
String | message | The message to log. |
Returns
Type | Description |
---|---|
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
notifyEmail(Integer)
This function sends a notify-email (a replyTemplate) to the owner of the ticket. To use for events like new ticket, new message on ticket etc.
Declaration
Bool notifyEmail(Integer replyTemplateId)
Parameters
Type | Name | Description |
---|---|---|
Integer | replyTemplateId | The ID of the replyTemplate you want to send. |
Returns
Type | Description |
---|---|
Bool |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
save()
Saves the ticket and returns the database ID of the stored ticket.
Declaration
Integer save()
Returns
Type | Description |
---|---|
Integer | The ID of the saved ticket. |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
save(Bool,Bool)
Saves the ticket and returns the database ID of the stored ticket.
Declaration
Integer save(Bool setReadStatus,Bool doNotCheckEscalating)
Parameters
Type | Name | Description |
---|---|---|
Bool | setReadStatus | Whether to calculate and set the read status on save. True = yes |
Bool | doNotCheckEscalating | True if you do NOT want the changes done on the ticket to result in a possible escalation, otherwise false. |
Returns
Type | Description |
---|---|
Integer | The ID of the saved ticket. |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
save(String)
Saves the ticket and returns the database ID of the stored ticket.
Declaration
Integer save(String log)
Parameters
Type | Name | Description |
---|---|---|
String | log | A String that will be saved in the log of the ticket. |
Returns
Type | Description |
---|---|
Integer | The ID of the saved ticket. |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
save(String,Bool,Bool)
Saves the ticket and returns the database ID of the stored ticket.
Declaration
Integer save(String log,Bool setReadStatus,Bool doNotCheckEscalating)
Parameters
Type | Name | Description |
---|---|---|
String | log | A String that will be saved in the log of the ticket |
Bool | setReadStatus | Whether to calculate and set the read status on save. True = yes |
Bool | doNotCheckEscalating | True if you do NOT want the changes done on the ticket to result in a possible escalation, otherwise false. |
Returns
Type | Description |
---|---|
Integer | The ID of the saved ticket. |
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
sendMessages(String,StringMatrix,Bool,String,Integer,String)
Will send the given messages just like the forward ticket functionality in the GUI. The forwarded messages are separated by a line, and the comment is placed on top of the mail.
Declaration
Bool sendMessages(String subject, StringMatrix recipients, Bool fromCust, String messages, Integer msgId, String comment)
Parameters
Type | Name | Description |
---|---|---|
String | subject | The mail subject, maybe ticket.title. |
StringMatrix | recipients | String matrix with recipients |
Bool | fromCust | Email address from ticket or customer |
String | messages | Comma-separated list of message IDs to forward |
Integer | msgId | ID of added 'forward' message or -1 |
String | comment | A comment that will be above the forwarded messages. |
Returns
Type | Description |
---|---|
Bool |
Remarks
The recipients string matrix is formatted like this:
To | John Doe <john.doe@john.doe> Cc | jane Doe <jane.doe@jane.doe>Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
setValue(String,String)
Sets column colName to the given value. Obs: For this to actually affect the ticket, you will have to use the function save() after you have set all the values you want.
Declaration
Void setValue(String colName, String value)
Parameters
Type | Name | Description |
---|---|---|
String | colName | |
String | value |
Returns
Type | Description |
---|---|
Remarks
Possible values are the extrafields on the ticket and the following:
- category: the category ID
- ownedBy: (owned_by), the ID of the user who owns the ticket
- slevel: the security level of the ticket, See TicketSecurityLevel.
- priority: the id
- status: 1 = active, 2 = closed, 3 = postponed, 4 = deleted, 5 = composed
- ticketStatus: (ticket_status), the ID of the custom status field
- ticket_type/ticketType: the ID of the request type
- custId: the ID of the primary customer
- customers: comma-separated list of customer ids
- createdBy: the ID of the user who posted the ticket, 1 if the ticket is posted into the system
- author: a string containing the name of the ticket author
- activate: the datetime when the ticket was activated
- createdAt: (created_at), the datetime when the ticket was created
- repliedAt: (replied_at), the datetime when the ticket first was replied at
- stopEscalation
- readStatus (read_status)
- deadline
- filterAddress
- timeToClose
- realTimeToClose
- dbiAgentId
- dbiKey
- dbiLastModified
- saleId: ID of connected Sale
- projectId: ID of connected Project
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
toParser(Parser)
This function will fill the variable space of the Parser with all values of the ticket. As opposed to the function toParserRaw(), the String variables title and author are in html.
Declaration
Void toParser(Parser theParser)
Parameters
Type | Name | Description |
---|---|---|
Parser | theParser | The parser who will be filled with ticket-values. |
Returns
Type | Description |
---|---|
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner
toParserRaw(Parser)
This function fills the Parser with the values of the ticket. As opposed to the function toParser() who set several of the String-values as html, all these variables will be in plain text.
Declaration
toParserRaw(Parser theParser)
Parameters
Type | Name | Description |
---|---|---|
Parser | theParser | The parser who will be filled with ticket-values. |
Returns
Type | Description |
---|---|
Examples
Ticket t;
t.load(2); // Loads the ticket with id = 2
print(t.getValue("ticketStatus"));
t.setValue("title", "Test");
t.setValue("status", "1");
DateTime d; // Default value for DateTime is now
t.setValue("dbiLastModified", d.toString());
print(t.getOwnerEmail()); // Prints name and email of owner