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

# NSSaleEntity

> The Sale Entity contains the sale amount, currency, and sale members. Sales are linked to contacts, persons, and/or projects.

The Sale Entity contains the sale amount, currency, and sale members. Sales are linked to contacts, persons, and/or projects.

## Constructors

### NSSaleEntity()

```crmscript theme={null}
NSSaleEntity
```

Initializes a new instance of the NSSaleEntity class.

## Methods

## GetActiveErpLinks()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The number of active ERP links.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer activeErpLinks = thing.GetActiveErpLinks();
```

## GetActiveLinks()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - Number of active links to sale, document, appointment.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer activeLinks = thing.GetActiveLinks();
```

## GetAmount()

```crmscript theme={null}
Float GetAmount()
```

**Returns:** [CRMScript.Global.Float](CRMScript.Global.Float) - Total sale amount.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Float amount = thing.GetAmount();
```

## GetAppointment()

```crmscript theme={null}
NSAppointment GetAppointment()
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSAppointment appointment = thing.GetAppointment();
```

## GetAssociate()

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

**Returns:** [CRMScript.NetServer.NSAssociate](CRMScript.NetServer.NSAssociate) - The sale owner.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSAssociate associate = thing.GetAssociate();
```

## GetCompetitor()

```crmscript theme={null}
NSCompetitor GetCompetitor()
```

**Returns:** [CRMScript.NetServer.NSCompetitor](CRMScript.NetServer.NSCompetitor) - List of all possible competitors.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSCompetitor competitor = thing.GetCompetitor();
```

## GetCompleted()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The Sale completed state.

<Note>
  The completed state is either Started or Completed. NotStarted is treated as Started. The value maps to the Done database field.
</Note>

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer completed = thing.GetCompleted();
```

## GetContact()

```crmscript theme={null}
NSContact GetContact()
```

**Returns:** [CRMScript.NetServer.NSContact](CRMScript.NetServer.NSContact) - The contact associated with the sale. It may also be 0 if no contact is associated with the sale.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSContact contact = thing.GetContact();
```

## GetCreatedBy()

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

**Returns:** [CRMScript.NetServer.NSAssociate](CRMScript.NetServer.NSAssociate) - Who created to sale.

**Example:**

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

## GetCreatedDate()

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

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Registered date.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
DateTime createdDate = thing.GetCreatedDate();
```

## GetCredited()

```crmscript theme={null}
NSCredited GetCredited()
```

**Returns:** [CRMScript.NetServer.NSCredited](CRMScript.NetServer.NSCredited) - List of who is to be credited for the sale.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSCredited credited = thing.GetCredited();
```

## GetCurrency()

```crmscript theme={null}
NSCurrency GetCurrency()
```

**Returns:** [CRMScript.NetServer.NSCurrency](CRMScript.NetServer.NSCurrency) - The currency the sale object was sold in.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSCurrency currency = thing.GetCurrency();
```

## GetCustomFields()

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

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

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

**Example:**

```crmscript theme={null}
NSSaleEntity 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());
```

## GetEarning()

```crmscript theme={null}
Float GetEarning()
```

**Returns:** [CRMScript.Global.Float](CRMScript.Global.Float) - Earning on sale.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Float earning = thing.GetEarning();
```

## GetEarningPercent()

```crmscript theme={null}
Float GetEarningPercent()
```

**Returns:** [CRMScript.Global.Float](CRMScript.Global.Float) - Earning as percent of total.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Float earningPercent = thing.GetEarningPercent();
```

## GetExtraFields()

Gets the extra fields on SaleEntity as a map.

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

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

**Example:**

```crmscript theme={null}
NSSaleEntity 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());
```

## GetHeading()

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

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Sale heading (short description?).

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
String heading = thing.GetHeading();
```

## GetIsPublished()

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

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - Should this SaleEntity be published and visible to strangers?

## GetLinks()

```crmscript theme={null}
NSLink[] GetLinks()
```

**Returns:** [CRMScript.NetServer.NSLink](CRMScript.NetServer.NSLink)\[] - List of all elements linked to the sale.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSLink[] links = thing.GetLinks();
```

## GetNextDueDate()

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

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Next due date, this is a de.normalization of 'closest future activity date, or most recent if no future activities'.

<Note>
  Maintained by the system, but very convenient for searching.
</Note>

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
DateTime nextDueDate = thing.GetNextDueDate();
```

## GetNumber()

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

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Alphanumeric user field.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
String number = thing.GetNumber();
```

## GetPerson()

A sale may also be connected to a person. This must be a contact person registered on the current contact. This does not mean that a person is required.

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

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

**Example:**

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

## GetPostit()

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

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - The actual text, max 2047 significant characters even though it is stored as a larger data type on some databases.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
String postit = thing.GetPostit();
```

## GetProbability()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - Actual probability, may differ from the one in the list.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer probability = thing.GetProbability();
```

## GetProject()

A sale may also be connected to a project, so you see the sale both on the company card, and on the project card. This does not mean that a project is required.

```crmscript theme={null}
NSProject GetProject()
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSProject project = thing.GetProject();
```

## GetPublishEventDate()

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

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Publish event date on SaleEntity.

## GetPublishFrom()

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

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Publish from date on SaleEntity.

## GetPublishTo()

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

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Publish to date on SaleEntity. After this date the event is no longer visible.

## GetRating()

```crmscript theme={null}
NSRating GetRating()
```

**Returns:** [CRMScript.NetServer.NSRating](CRMScript.NetServer.NSRating) - The sale rating.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSRating rating = thing.GetRating();
```

## GetReason()

```crmscript theme={null}
NSReason GetReason()
```

**Returns:** [CRMScript.NetServer.NSReason](CRMScript.NetServer.NSReason) - The sale reason.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSReason reason = thing.GetReason();
```

## GetReasonSold()

```crmscript theme={null}
NSReasonSold GetReasonSold()
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSReasonSold reasonSold = thing.GetReasonSold();
```

## GetReasonStalled()

```crmscript theme={null}
NSReasonStalled GetReasonStalled()
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSReasonStalled reasonStalled = thing.GetReasonStalled();
```

## GetReopenDate()

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

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Date the sale is to be reopened; valid only for status=stalled. Not necessarily the same as the nextDueDate.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
DateTime reopenDate = thing.GetReopenDate();
```

## GetSaledate()

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

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - (expected / lost / won) sales date.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
DateTime saledate = thing.GetSaledate();
```

## GetSaleId()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - Primary key.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer saleId = thing.GetSaleId();
```

## GetSaleStakeholders()

```crmscript theme={null}
NSSaleStakeholder[] GetSaleStakeholders()
```

**Returns:** [CRMScript.NetServer.NSSaleStakeholder](CRMScript.NetServer.NSSaleStakeholder)\[]

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSSaleStakeholder[] saleStakeholders = thing.GetSaleStakeholders();
```

## GetSaleText()

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

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Text describing the sale.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
String saleText = thing.GetSaleText();
```

## GetSaleType()

```crmscript theme={null}
NSSaleType GetSaleType()
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSSaleType saleType = thing.GetSaleType();
```

## GetSource()

```crmscript theme={null}
NSSource GetSource()
```

**Returns:** [CRMScript.NetServer.NSSource](CRMScript.NetServer.NSSource) - The sale source.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSSource source = thing.GetSource();
```

## GetStatus()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The state of the Sale (Open, Sold, Lost, Stalled). See \<xref href="CRMScript.NetServer.SaleStatus" data-throw-if-not-resolved="false">\</xref>.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer status = thing.GetStatus();
```

## GetUpdatedBy()

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

**Returns:** [CRMScript.NetServer.NSAssociate](CRMScript.NetServer.NSAssociate) - Who updated the sale.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSAssociate updatedBy = thing.GetUpdatedBy();
```

## GetUpdatedDate()

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

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Last updated.

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
DateTime updatedDate = thing.GetUpdatedDate();
```

## GetUserDefinedFields()

Gets the user-defined fields on the SaleEntity as a map.

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

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

**Example:**

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

## GetVisibleFor()

Returns the user groups and/or users the SaleEntity item is visible for.

```crmscript theme={null}
NSVisibleFor[] GetVisibleFor()
```

**Returns:** [CRMScript.NetServer.NSVisibleFor](CRMScript.NetServer.NSVisibleFor)\[]

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSVisibleFor[] visibleFor = thing.GetVisibleFor();
```

## SetActiveErpLinks(Integer)

```crmscript theme={null}
Void SetActiveErpLinks(Integer activeErpLinks)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer activeErpLinks;
thing.SetActiveErpLinks(activeErpLinks);
```

## SetActiveLinks(Integer)

```crmscript theme={null}
Void SetActiveLinks(Integer activeLinks)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer activeLinks;
thing.SetActiveLinks(activeLinks);
```

## SetAmount(Float)

```crmscript theme={null}
Void SetAmount(Float amount)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Float amount;
thing.SetAmount(amount);
```

## SetAppointment(NSAppointment)

```crmscript theme={null}
Void SetAppointment(NSAppointment appointment)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSAppointment appointment;
thing.SetAppointment(appointment);
```

## SetAssociate(NSAssociate)

```crmscript theme={null}
Void SetAssociate(NSAssociate associate)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSAssociate associate;
thing.SetAssociate(associate);
```

## SetCompetitor(NSCompetitor)

```crmscript theme={null}
Void SetCompetitor(NSCompetitor competitor)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSCompetitor competitor;
thing.SetCompetitor(competitor);
```

## SetCompleted(Integer)

```crmscript theme={null}
Void SetCompleted(Integer completed)
```

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

<Note>
  The completed state is either Started or Completed. NotStarted is treated as Started. The value maps to the Done database field.
</Note>

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer completed;
thing.SetCompleted(completed);
```

## SetContact(NSContact)

```crmscript theme={null}
Void SetContact(NSContact contact)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSContact contact;
thing.SetContact(contact);
```

## SetCreatedBy(NSAssociate)

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

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

**Example:**

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

## SetCreatedDate(DateTime)

Registered date

```crmscript theme={null}
Void SetCreatedDate(DateTime createdDate)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
DateTime createdDate;
thing.SetCreatedDate(createdDate);
```

## SetCredited(NSCredited)

```crmscript theme={null}
Void SetCredited(NSCredited credited)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSCredited credited;
thing.SetCredited(credited);
```

## SetCurrency(NSCurrency)

```crmscript theme={null}
Void SetCurrency(NSCurrency currency)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSCurrency currency;
thing.SetCurrency(currency);
```

## SetCustomFields(Map)

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

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

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

**Example:**

```crmscript theme={null}
NSSaleEntity 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);
```

## SetEarning(Float)

```crmscript theme={null}
Void SetEarning(Float earning)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Float earning;
thing.SetEarning(earning);
```

## SetEarningPercent(Float)

```crmscript theme={null}
Void SetEarningPercent(Float earningPercent)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Float earningPercent;
thing.SetEarningPercent(earningPercent);
```

## SetExtraFields(Map)

Sets the extra field values on SaleEntity with a map.

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

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

**Example:**

```crmscript theme={null}
NSSaleEntity 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);
```

## SetHeading(String)

```crmscript theme={null}
Void SetHeading(String heading)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
String heading;
thing.SetHeading(heading);
```

## SetIsPublished(Bool)

Sets the visibility of the entity

```crmscript theme={null}
Void SetIsPublished(Bool isPublished)
```

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

## SetLinks(NSLink\[])

```crmscript theme={null}
Void SetLinks(NSLink[] links)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSLink[] links;
thing.SetLinks(links);
```

## SetNextDueDate(DateTime)

Maintained by the system, but very convenient for searching.

```crmscript theme={null}
Void SetNextDueDate(DateTime nextDueDate)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
DateTime nextDueDate;
thing.SetNextDueDate(nextDueDate);
```

## SetNumber(String)

```crmscript theme={null}
Void SetNumber(String number)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
String number;
thing.SetNumber(number);
```

## SetPerson(NSPerson)

A sale may also be connected to a person. This must be a contact person registered on the current contact. This does not mean that a person is required.

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

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

**Example:**

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

## SetPostit(String)

```crmscript theme={null}
Void SetPostit(String postit)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
String postit;
thing.SetPostit(postit);
```

## SetProbability(Integer)

```crmscript theme={null}
Void SetProbability(Integer probability)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer probability;
thing.SetProbability(probability);
```

## SetProject(NSProject)

A sale may also be connected to a project, so you see the sale both on the company card, and on the project card. This does not mean that a project is required.

```crmscript theme={null}
Void SetProject(NSProject project)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSProject project;
thing.SetProject(project);
```

## SetPublishEventDate(DateTime)

```crmscript theme={null}
Void SetPublishEventDate(DateTime publishDate)
```

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

## SetPublishFrom(DateTime)

Sets the publish from date on a SaleEntity.

```crmscript theme={null}
Void SetPublishFrom(DateTime publishFrom)
```

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

## SetPublishTo(DateTime)

Sets the publish to date on SaleEntity.

```crmscript theme={null}
Void SetPublishTo(DateTime publishTo)
```

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

## SetRating(NSRating)

```crmscript theme={null}
Void SetRating(NSRating rating)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSRating rating;
thing.SetRating(rating);
```

## SetReason(NSReason)

```crmscript theme={null}
Void SetReason(NSReason reason)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSReason reason;
thing.SetReason(reason);
```

## SetReasonSold(NSReasonSold)

```crmscript theme={null}
Void SetReasonSold(NSReasonSold reasonSold)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSReasonSold reasonSold;
thing.SetReasonSold(reasonSold);
```

## SetReasonStalled(NSReasonStalled)

```crmscript theme={null}
Void SetReasonStalled(NSReasonStalled reasonStalled)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSReasonStalled reasonStalled;
thing.SetReasonStalled(reasonStalled);
```

## SetReopenDate(DateTime)

```crmscript theme={null}
Void SetReopenDate(DateTime reopenDate)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
DateTime reopenDate;
thing.SetReopenDate(reopenDate);
```

## SetSaledate(DateTime)

```crmscript theme={null}
Void SetSaledate(DateTime saledate)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
DateTime saledate;
thing.SetSaledate(saledate);
```

## SetSaleId(Integer)

```crmscript theme={null}
Void SetSaleId(Integer saleId)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer saleId;
thing.SetSaleId(saleId);
```

## SetSaleStakeholders(NSSaleStakeholder\[])

```crmscript theme={null}
Void SetSaleStakeholders(NSSaleStakeholder[] saleStakeholders)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSSaleStakeholder[] saleStakeholders;
thing.SetSaleStakeholders(saleStakeholders);
```

## SetSaleText(String)

```crmscript theme={null}
Void SetSaleText(String saleText)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
String saleText;
thing.SetSaleText(saleText);
```

## SetSaleType(NSSaleType)

```crmscript theme={null}
Void SetSaleType(NSSaleType saleType)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSSaleType saleType;
thing.SetSaleType(saleType);
```

## SetSource(NSSource)

```crmscript theme={null}
Void SetSource(NSSource source)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSSource source;
thing.SetSource(source);
```

## SetStatus(Integer)

```crmscript theme={null}
Void SetStatus(Integer status)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
Integer status;
thing.SetStatus(status);
```

## SetUpdatedBy(NSAssociate)

```crmscript theme={null}
Void SetUpdatedBy(NSAssociate updatedBy)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSAssociate updatedBy;
thing.SetUpdatedBy(updatedBy);
```

## SetUpdatedDate(DateTime)

```crmscript theme={null}
Void SetUpdatedDate(DateTime updatedDate)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
DateTime updatedDate;
thing.SetUpdatedDate(updatedDate);
```

## SetUserDefinedFields(Map)

Sets the user-defined fields on the SaleEntity as a map.

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

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

**Example:**

```crmscript theme={null}
NSSaleEntity 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";
thing.SetUserDefinedFields(udefs);
```

## SetVisibleFor(NSVisibleFor\[])

Sets the user groups and/or users the SaleEntity item is visible for.

```crmscript theme={null}
Void SetVisibleFor(NSVisibleFor[] visibleFor)
```

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

**Example:**

```crmscript theme={null}
NSSaleEntity thing;
NSVisibleFor[] visibleFor = thing.GetVisibleFor();
visibleFor[0].SetVisiblity(1);  // usergroup
visibleFor[0].SetVisibleId(123); // usergroup id
thing.SetVisibleFor(visibleFor);
```


## Related topics

- [NSSaleAgent](/en/automation/crmscript/reference/CRMScript.NetServer.NSSaleAgent.md)
- [Lost or sold sales](/en/automation/crmscript/howto/sale/lost-or-sold.md)
- [Retrieve a sale](/en/automation/crmscript/howto/sale/get.md)
- [Sales](/en/sale/dev/index.md)
- [Validate Sale Entity](/en/api/reference/restful/agent/sale_agent/validate-sale-entity.md)
- [Delete Sale Entity](/en/api/reference/restful/agent/sale_agent/delete-sale-entity.md)
