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

# NSFavouriteAgent

> Agent used for retrieving and setting favorites.

Agent used for retrieving and setting favorites.

## Constructors

### NSFavouriteAgent()

```crmscript theme={null}
NSFavouriteAgent
```

Agent used for retrieving and setting favorites.

## Methods

## AddFavourite(String,Integer,Integer,String)

Adds a record in a table as a favorite for an associate

```crmscript theme={null}
Void AddFavourite(String tableName, Integer recordId, Integer associateId, String extraInfo)
```

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

## AddFavourites(String,Integer\[],Integer,String)

Adds a list of record IDs as favorites for an associate

```crmscript theme={null}
Void AddFavourites(String tableName, Integer[] recordIds, Integer associateId, String extraInfo)
```

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

## GetFavourites(String,Integer)

Gets all favorites for a table and associate

```crmscript theme={null}
NSFavourite[] GetFavourites(String tableName, Integer associateId)
```

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

## IsFavourite(String,Integer,Integer)

Checks if a record in a table is a favorite for an associate

```crmscript theme={null}
Bool IsFavourite(String tableName, Integer recordId, Integer associateId)
```

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

## RemoveAllFavourites(String,Integer)

Removes all favorites for a table and associate

```crmscript theme={null}
Void RemoveAllFavourites(String tableName, Integer associateId)
```

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

## RemoveFavourite(String,Integer,Integer)

Removes favorite for a table, record ID, and associate

```crmscript theme={null}
Void RemoveFavourite(String tableName, Integer recordId, Integer associateId)
```

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

## RemoveFavouritesById(Integer\[])

Removes favorite using favorite ID

```crmscript theme={null}
Void RemoveFavouritesById(Integer[] favoriteIds)
```

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

## ToggleFavourite(String,Integer,Integer,String)

Toggles a record in a table as a favorite for an associate

```crmscript theme={null}
Bool ToggleFavourite(String tableName, Integer recordId, Integer associateId, String extraInfo)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - true if added; false if removed.

**Example:**

```crmscript theme={null}
NSFavouriteAgent agent;
String tableName;
Integer recordId;
Integer associateId;
String extraInfo;
Bool res = agent.ToggleFavourite(tableName, recordId, associateId, extraInfo);
```


## Related topics

- [SuperOffice.WebApi.Agents.FavouriteAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.FavouriteAgent.md)
- [SuperOffice.WebApi.Agents.IFavouriteAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.IFavouriteAgent.md)
- [Is Favourite](/en/api/reference/restful/agent/favourite_agent/is-favourite.md)
- [Favourites](/en/api/archive-providers/reference/favourites.md)
- [Get Favourites](/en/api/reference/restful/agent/favourite_agent/get-favourites.md)
- [Remove Favourite](/en/api/reference/restful/agent/favourite_agent/remove-favourite.md)
