> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ticket

> Class for representing an SuperOffice Service Ticket.

Class for representing an SuperOffice Service Ticket.

## Constructors

### Ticket()

```crmscript theme={null}
Ticket
```

Class for representing an SuperOffice Service Ticket.

## Methods

## buildEmailSubject()

returns a String composed by the Mail tag, the ticketId and the title of the ticket

```crmscript theme={null}
String buildEmailSubject()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - A String composed by the Mail tag, the ticketId and the title of the ticket.

## 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.

```crmscript theme={null}
Void checkEscalating(Integer action)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  Possible values:

  * ActionRead = 0
  * ActionChangedOwner = 1
  * ActionNewInfo = 2
  * ActionClosed = 3
  * ActionChangedPriority = 4
  * ActionNew = 5
</Note>

## delegate()

Delegates a ticket to a user according to the rules on the category.

For this function to take effect, you have to call \<code>Ticket.save()\</code>.

```crmscript theme={null}
delegate()
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## 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 call \<code>Ticket.save()\</code>.

```crmscript theme={null}
delegate(Integer notUser)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## 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.

```crmscript theme={null}
String getInvolvedOnly()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - A comma-separated list of email-addresses.

## getMailFrom()

This function determines and returns the most appropriate from-address, when sending a mail-message on a ticket.

```crmscript theme={null}
String getMailFrom()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - The most appropriate from-address specified on with address, the ticket has arrived on, the category, etc.

## getOwnerEmail()

This function returns the owner of the ticket printed as "Name" \<email-addr>.

```crmscript theme={null}
String getOwnerEmail()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - The owners name and email-address.

## getOwnerSms()

This function returns the cellphone number of the owner of the ticket

```crmscript theme={null}
String getOwnerSms()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - The cellphone number of the owner of the ticket as a String.

## getValue(String)

Gets the value of given column name as a String

```crmscript theme={null}
String getValue(String colName)
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Returns a string representation of the wanted value.

<Note>
  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
</Note>

## load(Integer)

Load ticket with given id into this object, return true if successful, false otherwise.

```crmscript theme={null}
Bool load(Integer id)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool)

## log(String)

Writes a message to the ticket log. Used for logging changes and events on a ticket

```crmscript theme={null}
log(String message)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## log(String,String)

Writes a message to the ticket log. Used for logging changes and events on a ticket

```crmscript theme={null}
log(String who, String message)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## 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.

```crmscript theme={null}
Bool notifyEmail(Integer replyTemplateId)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool)

## save()

Saves the ticket and returns the database ID of the stored ticket.

```crmscript theme={null}
Integer save()
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The ID of the saved ticket.

## save(String)

Saves the ticket and returns the database ID of the stored ticket.

```crmscript theme={null}
Integer save(String log)
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The ID of the saved ticket.

## save(Bool,Bool)

Saves the ticket and returns the database ID of the stored ticket.

```crmscript theme={null}
Integer save(Bool setReadStatus,Bool doNotCheckEscalating)
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The ID of the saved ticket.

## save(String,Bool,Bool)

Saves the ticket and returns the database ID of the stored ticket.

```crmscript theme={null}
Integer save(String log,Bool setReadStatus,Bool doNotCheckEscalating)
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The ID of the saved ticket.

## 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.

```crmscript theme={null}
Bool sendMessages(String subject, StringMatrix recipients, Bool fromCust, String messages, Integer msgId, String comment)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool)

<Note>
  The recipients string matrix is formatted like this:

  To | John Doe \<[john.doe@john.doe](mailto:john.doe@john.doe)> Cc | jane Doe \<[jane.doe@jane.doe](mailto:jane.doe@jane.doe)>
</Note>

## 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.

```crmscript theme={null}
Void setValue(String colName, String value)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  Possible values are the extrafields on the ticket and the following:\</p>

  * category: the category ID
  * ownedBy: (owned\_by), the ID of the user who owns the ticket
  * slevel: the security level of the ticket, See \<xref href="CRMScript.NetServer.TicketSecurityLevel" data-throw-if-not-resolved="false">\</xref>.
  * 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
</Note>

## 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.

```crmscript theme={null}
Void toParser(Parser theParser)
```

**Parameters:**

| Name      | Type                                               | Description                                       |
| --------- | -------------------------------------------------- | ------------------------------------------------- |
| theParser | [CRMScript.Native.Parser](CRMScript.Native.Parser) | The parser who will be filled with ticket-values. |

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## 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.

```crmscript theme={null}
toParserRaw(Parser theParser)
```

**Parameters:**

| Name      | Type                                               | Description                                       |
| --------- | -------------------------------------------------- | ------------------------------------------------- |
| theParser | [CRMScript.Native.Parser](CRMScript.Native.Parser) | The parser who will be filled with ticket-values. |

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)


## Related topics

- [ticket](/en/api/mdo-providers/reference/ticket.md)
- [Ticket](/en/api/archive-providers/reference/ticket.md)
- [Tickets](/en/api/reference/restful/rest/person/tickets.md)
- [ticket_freetextsearch](/en/api/mdo-providers/reference/ticket_freetextsearch.md)
- [Accept Tickets](/en/api/reference/restful/agent/ticket_agent/accept-tickets.md)
