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

# NSTicketMessageEntity

> The ticket messages are e-mails, SMS or other messages attached to a ticket (aka request).

The ticket messages are e-mails, SMS or other messages attached to a ticket (aka request).

## Constructors

### NSTicketMessageEntity()

```crmscript theme={null}
NSTicketMessageEntity
```

Initializes a new instance of the NSTicketMessageEntity class.

## Methods

## GetAuthor()

A string representing the author of the message. Could be a user's name, or a persons email address.

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

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String author = thing.GetAuthor();
```

## GetBody()

The textbody for the message.

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

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String body = thing.GetBody();
```

## GetCreatedAt()

When the message was posted.

```crmscript theme={null}
DateTime GetCreatedAt()
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
DateTime createdAt = thing.GetCreatedAt();
```

## GetCreatedBy()

The associate who created this ticket message

```crmscript theme={null}
NSAssociate GetCreatedBy()
```

**Returns:** [CRMScript.NetServer.NSAssociate](CRMScript.NetServer.NSAssociate)

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
NSAssociate createdBy = thing.GetCreatedBy();
```

## GetCustomFields()

Gets the user-defined + extra fields on a TicketMessageEntity as a map.

```crmscript theme={null}
Map GetCustomFields()
```

**Returns:** [CRMScript.Native.Map](CRMScript.Native.Map)

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Map fields = thing.GetCustomFields();
String oldValue = fields.get("SuperOffice:1");
fields.insert("SuperOffice:1", "NewValue");
for (fields.first(); !fields.eof(); fields.next())
  printLine(fields.getKey() + ":  " + fields.getVal());
```

## GetDebugInfo()

The debug info for the message.

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

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String debugInfo = thing.GetDebugInfo();
```

## GetEjMessageId()

The primary key (auto-incremented)

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

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Integer ejMessageId = thing.GetEjMessageId();
```

## GetEmailHeader()

The email header is saved in this field as raw text

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

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String emailHeader = thing.GetEmailHeader();
```

## GetExtraFields()

Gets the extra fields on TicketMessageEntity as a map.

```crmscript theme={null}
Map GetExtraFields()
```

**Returns:** [CRMScript.Native.Map](CRMScript.Native.Map)

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Map fields = thing.GetExtraFields();
String oldValue = fields.get("x_foobar");
fields.insert("x_foobar", "NewValue");
for (fields.first(); !fields.eof(); fields.next())
  printLine(fields.getKey() + ":  " + fields.getVal());
```

## GetHtmlBody()

The HTML body for the message (if any).

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

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String htmlBody = thing.GetHtmlBody();
```

## GetImportant()

If this message is important or not.

```crmscript theme={null}
Bool GetImportant()
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Bool important = thing.GetImportant();
```

## GetMailSorter()

The name of the mail sorter used when the email was imported. Note: We must use name instead of id since the id's change every time one changes the mail sorter. :-0

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

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String mailSorter = thing.GetMailSorter();
```

## GetMessageCategory()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - Defines what kind of message this is. See \<xref href="CRMScript.NetServer.TicketMessageCategory" data-throw-if-not-resolved="false">\</xref>.

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Integer messageCategory = thing.GetMessageCategory();
```

## GetMessageHeaders()

```crmscript theme={null}
NSTicketMessageHeader[] GetMessageHeaders()
```

**Returns:** [CRMScript.NetServer.NSTicketMessageHeader](CRMScript.NetServer.NSTicketMessageHeader)\[] - Contains the message headers, like To, Cc, Bcc information, or custom headers.

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
TicketMessageHeader[] messageHeaders = thing.GetMessageHeaders();
```

## GetMessageId()

The X-Message-Id header value from the email. Used for threading, i.e. connecting messages to existing tickets.

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

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String messageId = thing.GetMessageId();
```

## GetPerson()

If this is an incoming message, this will contain the person

```crmscript theme={null}
NSPerson GetPerson()
```

**Returns:** [CRMScript.NetServer.NSPerson](CRMScript.NetServer.NSPerson)

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
NSPerson person = thing.GetPerson();
```

## GetSearchTitle()

A copy of the title of the ticket, for search optimization and simpler reporting.

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

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String searchTitle = thing.GetSearchTitle();
```

## GetSlevel()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The security level of the message. See \<xref href="CRMScript.NetServer.TicketSecurityLevel" data-throw-if-not-resolved="false">\</xref>.

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Integer slevel = thing.GetSlevel();
```

## GetTicket()

The connected ticket

```crmscript theme={null}
NSTicket GetTicket()
```

**Returns:** [CRMScript.NetServer.NSTicket](CRMScript.NetServer.NSTicket)

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
NSTicket ticket = thing.GetTicket();
```

## GetTimeSpent()

The time spent (minutes) for this message.

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

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Integer timeSpent = thing.GetTimeSpent();
```

## GetType()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The type of the message (plaintext/html). See \<xref href="CRMScript.NetServer.TicketMessageType" data-throw-if-not-resolved="false">\</xref>.

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Integer type = thing.GetType();
```

## SetAuthor(String)

A string representing the author of the message. Could be a user's name, or a persons email address.

```crmscript theme={null}
Void SetAuthor(String author)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String author;
thing.SetAuthor(author);
```

## SetBody(String)

The textbody for the message.

```crmscript theme={null}
Void SetBody(String body)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String body;
thing.SetBody(body);
```

## SetCreatedAt(DateTime)

When the message was posted.

```crmscript theme={null}
Void SetCreatedAt(DateTime createdAt)
```

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
DateTime createdAt;
thing.SetCreatedAt(createdAt);
```

## SetCreatedBy(NSAssociate)

The associate who created this ticket message

```crmscript theme={null}
Void SetCreatedBy(NSAssociate createdBy)
```

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
NSAssociate createdBy;
thing.SetCreatedBy(createdBy);
```

## SetCustomFields(Map)

Sets the user-defined and extra fields on a TicketMessageEntity with a map.

```crmscript theme={null}
Void SetCustomFields(Map udefs)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Map udefs;
udefs["SuperOffice:1"] = "[I:123]";
udefs["SuperOffice:1"] = "123"; // this will also work, but beware of decimal point variations in different languages
udefs["custom.progid"] = "foobar";
udefs["x_foo"] = "foobar";
udefs["x_bar"] = "456"; // List item id
thing.SetCustomFields(udefs);
```

## SetDebugInfo(String)

The debug info for the message.

```crmscript theme={null}
Void SetDebugInfo(String debugInfo)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String debugInfo;
thing.SetDebugInfo(debugInfo);
```

## SetEjMessageId(Integer)

The primary key (auto-incremented)

```crmscript theme={null}
Void SetEjMessageId(Integer ejMessageId)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Integer ejMessageId;
thing.SetEjMessageId(ejMessageId);
```

## SetEmailHeader(String)

The email header is saved in this field as raw text

```crmscript theme={null}
Void SetEmailHeader(String emailHeader)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String emailHeader;
thing.SetEmailHeader(emailHeader);
```

## SetExtraFields(Map)

Sets the extra field values on TicketMessageEntity with a map.

```crmscript theme={null}
Void SetExtraFields(Map extras)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Map extras;
extras["SuperOffice:1"] = "[I:123]";
extras["SuperOffice:1"] = "123"; // this will also work, but beware of decimal point variations in different languages
extras["custom.progid"] = "foobar";
thing.SetExtraFields(extras);
```

## SetHtmlBody(String)

The HTML body for the message (if any).

```crmscript theme={null}
Void SetHtmlBody(String htmlBody)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String htmlBody;
thing.SetHtmlBody(htmlBody);
```

## SetImportant(Bool)

If this message is important or not.

```crmscript theme={null}
Void SetImportant(Bool important)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Bool important;
thing.SetImportant(important);
```

## SetMailSorter(String)

The name of the mail sorter used when the email was imported. Note: We must use name instead of id since the id's change every time one changes the mail sorter. :-0

```crmscript theme={null}
Void SetMailSorter(String mailSorter)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String mailSorter;
thing.SetMailSorter(mailSorter);
```

## SetMessageCategory(Integer)

```crmscript theme={null}
Void SetMessageCategory(Integer messageCategory)
```

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Integer messageCategory;
thing.SetMessageCategory(messageCategory);
```

## SetMessageHeaders(NSTicketMessageHeader\[])

```crmscript theme={null}
Void SetMessageHeaders(NSTicketMessageHeader[] messageHeaders)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
NSTicketMessageHeader[] messageHeaders;
thing.SetMessageHeaders(messageHeaders);
```

## SetMessageId(String)

The X-Message-Id header value from the email. Used for threading, i.e. connecting messages to existing tickets.

```crmscript theme={null}
Void SetMessageId(String messageId)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String messageId;
thing.SetMessageId(messageId);
```

## SetPerson(NSPerson)

If this is an incoming message, this will contain the person

```crmscript theme={null}
Void SetPerson(NSPerson person)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
NSPerson person;
thing.SetPerson(person);
```

## SetSearchTitle(String)

A copy of the title of the ticket, for search optimisation and simpler reporting.

```crmscript theme={null}
Void SetSearchTitle(String searchTitle)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
String searchTitle;
thing.SetSearchTitle(searchTitle);
```

## SetSlevel(Integer)

```crmscript theme={null}
Void SetSlevel(Integer slevel)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Integer slevel;
thing.SetSlevel(slevel);
```

## SetTicket(NSTicket)

The connected ticket

```crmscript theme={null}
Void SetTicket(NSTicket ticket)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
NSTicket ticket;
thing.SetTicket(ticket);
```

## SetTimeSpent(Integer)

The time spent (minutes) for this message.

```crmscript theme={null}
Void SetTimeSpent(Integer timeSpent)
```

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

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Integer timeSpent;
thing.SetTimeSpent(timeSpent);
```

## SetType(Integer)

```crmscript theme={null}
Void SetType(Integer type)
```

**Example:**

```crmscript theme={null}
NSTicketMessageEntity thing;
Integer type;
thing.SetType(type);
```


## Related topics

- [NSTicketAgent](/en/automation/crmscript/reference/CRMScript.NetServer.NSTicketAgent.md)
- [NSTicketEntity](/en/automation/crmscript/reference/CRMScript.NetServer.NSTicketEntity.md)
- [Delete Ticket Message Entity](/en/api/reference/restful/rest/ticketmessage/delete-ticket-message-entity.md)
- [Default Ticket Message Entity](/en/api/reference/restful/rest/ticketmessage/default-ticket-message-entity.md)
- [Save Ticket Message Entity](/en/api/reference/restful/agent/ticket_agent/save-ticket-message-entity.md)
