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

# NSReportAgent

> Run reports, set favorites, labels.

Run reports, set favorites, labels.

## Constructors

### NSReportAgent()

```crmscript theme={null}
NSReportAgent
```

Run reports, set favorites, labels.

## Methods

## CreateDefaultReportEntity()

Sets default values into a new NSReportEntity.

```crmscript theme={null}
NSReportEntity CreateDefaultReportEntity()
```

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

<Note>
  NetServer calculates default values (for example, Country) on the entity, which is required when creating/storing a new instance
</Note>

**Example:**

```crmscript theme={null}
NSReportAgent agent;
NSReportEntity thing = agent.CreateDefaultReportEntity();
thing = agent.SaveReportEntity(thing);
```

## CreateDefaultReportLabelLayoutEntity()

Sets default values into a new NSReportLabelLayoutEntity.

```crmscript theme={null}
NSReportLabelLayoutEntity CreateDefaultReportLabelLayoutEntity()
```

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

<Note>
  NetServer calculates default values (for example, Country) on the entity, which is required when creating/storing a new instance
</Note>

**Example:**

```crmscript theme={null}
NSReportAgent agent;
NSReportLabelLayoutEntity thing = agent.CreateDefaultReportLabelLayoutEntity();
thing = agent.SaveReportLabelLayoutEntity(thing);
```

## CreateFavorite(Integer,String,String)

Creates the report as favorite.

```crmscript theme={null}
NSReportEntity CreateFavorite(Integer sourceId, String name, String description)
```

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

**Example:**

```crmscript theme={null}
NSReportAgent agent;
Integer sourceId;
String name;
String description;
NSReportEntity res = agent.CreateFavorite(sourceId, name, description);
```

## DeleteFavorite(Integer)

Deletes the report favorite.

```crmscript theme={null}
Void DeleteFavorite(Integer reportEntityId)
```

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

## DeleteReport(Integer)

Deletes the report with the given ID.

```crmscript theme={null}
Bool DeleteReport(Integer reportId)
```

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

**Example:**

```crmscript theme={null}
NSReportAgent agent;
Integer reportId;
Bool res = agent.DeleteReport(reportId);
```

## DeleteReportLabelLayoutEntity(Integer)

Deletes the NSReportLabelLayoutEntity

```crmscript theme={null}
DeleteReportLabelLayoutEntity(Integer reportLabelLayoutEntity)
```

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

**Example:**

```crmscript theme={null}
NSReportAgent agent;
agent.DeleteReportLabelLayoutEntity(123);
```

## GenerateReport(Integer,Integer,String,String,String,NSArchiveRestrictionInfo\[])

Generates the report in PDF format.

```crmscript theme={null}
String GenerateReport(Integer reportId, Integer labelLayoutId, String filename, String language, String fileType, NSArchiveRestrictionInfo[] restrictions)
```

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

**Example:**

```crmscript theme={null}
NSReportAgent agent;
Integer reportId;
Integer labelLayoutId;
String filename;
String language;
String fileType;
NSArchiveRestrictionInfo[] restrictions;
String res = agent.GenerateReport(reportId, labelLayoutId, filename, language, fileType, restrictions);
```

## GetReportEntity(Integer)

Gets an NSReportEntity object.

```crmscript theme={null}
NSReportEntity GetReportEntity(Integer reportEntityId)
```

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

**Example:**

```crmscript theme={null}
NSReportAgent agent;
NSReportEntity thing = agent.GetReportEntity(123);
```

## GetReportLabelLayoutEntity(Integer)

Gets an NSReportLabelLayoutEntity object.

```crmscript theme={null}
NSReportLabelLayoutEntity GetReportLabelLayoutEntity(Integer reportLabelLayoutEntityId)
```

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

**Example:**

```crmscript theme={null}
NSReportAgent agent;
NSReportLabelLayoutEntity thing = agent.GetReportLabelLayoutEntity(123);
```

## ImportReport(String)

Takes the input stream and create a report. This stream must be on a valid XML format.

```crmscript theme={null}
Integer ImportReport(String report)
```

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

**Example:**

```crmscript theme={null}
NSReportAgent agent;
String report;
Integer res = agent.ImportReport(report);
```

## SaveReportEntity(NSReportEntity)

Updates the existing NSReportEntity or creates a new NSReportEntity if the id parameter is 0

```crmscript theme={null}
NSReportEntity SaveReportEntity(NSReportEntity reportEntity)
```

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

**Example:**

```crmscript theme={null}
NSReport  agent;
NSReportEntity thing = agent.CreateDefaultReportEntity();
thing = agent.SaveReportEntity(thing);
```

## SaveReportLabelLayoutEntity(NSReportLabelLayoutEntity)

Updates the existing NSReportLabelLayoutEntity or creates a new NSReportLabelLayoutEntity if the ID parameter is 0.

```crmscript theme={null}
NSReportLabelLayoutEntity SaveReportLabelLayoutEntity(NSReportLabelLayoutEntity reportLabelLayoutEntity)
```

**Returns:** [CRMScript.NetServer.NSReportLabelLayoutEntity](CRMScript.NetServer.NSReportLabelLayoutEntity) - The new or updated NSReportLabelLayoutEntity.

**Example:**

```crmscript theme={null}
NSReport  agent;
NSReportLabelLayoutEntity thing = agent.CreateDefaultReportLabelLayoutEntity();
thing = agent.SaveReportLabelLayoutEntity(thing);
```

## UpdateFavorite(NSReportEntity)

Updates the favorite.

```crmscript theme={null}
NSReportEntity UpdateFavorite(NSReportEntity reportEntity)
```

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

**Example:**

```crmscript theme={null}
NSReportAgent agent;
NSReportEntity reportEntity;
NSReportEntity res = agent.UpdateFavorite(reportEntity);
```


## Related topics

- [SuperOffice.WebApi.Agents.ReportAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.ReportAgent.md)
- [SuperOffice.WebApi.Agents.IReportAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.IReportAgent.md)
- [Save Privacy Report](/en/api/reference/restful/agent/document_agent/save-privacy-report.md)
- [Report Session Active](/en/api/reference/restful/agent/customerservice_agent/report-session-active.md)
- [Compatibility reports](/en/onsite/compatibility/index.md)
- [ReportLabelLayout](/en/api/archive-providers/reference/reportlabellayout.md)
