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

# NSUser

> SuperOffice User, with login credentials and an associated person.

SuperOffice User, with login credentials and an associated person.

## Constructors

### NSUser()

```crmscript theme={null}
NSUser
```

Initializes a new instance of the NSUser class.

## Methods

## GetAssociateId()

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

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

**Example:**

```crmscript theme={null}
NSUser thing;
Integer associateId = thing.GetAssociateId();
```

## GetCredentials()

```crmscript theme={null}
NSCredential[] GetCredentials()
```

**Returns:** [CRMScript.NetServer.NSCredential](CRMScript.NetServer.NSCredential)\[] - List of credentials registered for this user. i.e. valid authentication methods.

**Example:**

```crmscript theme={null}
NSUser thing;
NSCredential[] credentials = thing.GetCredentials();
```

## GetCustomFields()

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

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

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

**Example:**

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

## GetDeleted()

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

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - If true, the user is retired and should have no rights, not appear in lists, etc.

**Example:**

```crmscript theme={null}
NSUser thing;
Bool deleted = thing.GetDeleted();
```

## GetEjUserId()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - ID of the ej user record corresponding to this associate; 0 for associates that are not ej users.

**Example:**

```crmscript theme={null}
NSUser thing;
Integer ejUserId = thing.GetEjUserId();
```

## GetExtraFields()

Gets the extra fields on User as a map.

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

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

**Example:**

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

## GetIsOnTravel()

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

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if the user is on travel.

**Example:**

```crmscript theme={null}
NSUser thing;
Bool isOnTravel = thing.GetIsOnTravel();
```

## GetIsPersonRetired()

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

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if the user is retired and should have no rights, not appear in lists, etc.

**Example:**

```crmscript theme={null}
NSUser thing;
Bool isPersonRetired = thing.GetIsPersonRetired();
```

## GetLastlogin()

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

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

**Example:**

```crmscript theme={null}
NSUser thing;
DateTime lastlogin = thing.GetLastlogin();
```

## GetLastlogout()

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

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

**Example:**

```crmscript theme={null}
NSUser thing;
DateTime lastlogout = thing.GetLastlogout();
```

## GetLicenseOwners()

```crmscript theme={null}
NSLicenseOwner[] GetLicenseOwners()
```

**Returns:** [CRMScript.NetServer.NSLicenseOwner](CRMScript.NetServer.NSLicenseOwner)\[] - The restricted and unrestricted module licenses grouped by license owner.

<Note>
  These module licenses are either assigned or unassigned to this user
</Note>

**Example:**

```crmscript theme={null}
NSUser thing;
NSLicenseOwner[] licenseOwners = thing.GetLicenseOwners();
```

## GetName()

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

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Initials, UserId\* also used as login name for on-site installations. Identifies user in archives.

**Example:**

```crmscript theme={null}
NSUser thing;
String name = thing.GetName();
```

## GetNickName()

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

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - The unique nick name for this user. Used in Service as an alias, similar to Name/Initials.

**Example:**

```crmscript theme={null}
NSUser thing;
String nickName = thing.GetNickName();
```

## GetOtherGroups()

```crmscript theme={null}
NSUserGroup[] GetOtherGroups()
```

**Returns:** [CRMScript.NetServer.NSUserGroup](CRMScript.NetServer.NSUserGroup)\[] - The other groups this user is a member of, apart from the main user group.

**Example:**

```crmscript theme={null}
NSUser thing;
NSUserGroup[] otherGroups = thing.GetOtherGroups();
```

## GetPerson()

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

**Returns:** [CRMScript.NetServer.NSPerson](CRMScript.NetServer.NSPerson) - The person associated with this user. Detailed information about the user.

**Example:**

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

## GetRank()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - Rank order.

**Example:**

```crmscript theme={null}
NSUser thing;
Integer rank = thing.GetRank();
```

## GetRequestSignature()

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

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - ej users request signature.

**Example:**

```crmscript theme={null}
NSUser thing;
String requestSignature = thing.GetRequestSignature();
```

## GetRole()

```crmscript theme={null}
NSRole GetRole()
```

**Returns:** [CRMScript.NetServer.NSRole](CRMScript.NetServer.NSRole) - Users role for role-based security. Determines permissions and access rights for the user.

**Example:**

```crmscript theme={null}
NSUser thing;
NSRole role = thing.GetRole();
```

## GetTicketCategories()

```crmscript theme={null}
NSMDOListItem[] GetTicketCategories()
```

**Returns:** [CRMScript.NetServer.NSMDOListItem](CRMScript.NetServer.NSMDOListItem)\[] - Request Ticket Categories assigned to the user.

**Example:**

```crmscript theme={null}
NSUser thing;
NSMDOListItem[] ticketCategories = thing.GetTicketCategories();
```

## GetTooltip()

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

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Tooltip or other description.

**Example:**

```crmscript theme={null}
NSUser thing;
String tooltip = thing.GetTooltip();
```

## GetType()

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

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - NSUser type 1=InternalAssociate, 2=ResourceAssociate, 3=ExternalAssociate, 4=AnonymousAssociate, 5=SystemAssociate.

**Example:**

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

## GetUserGroup()

```crmscript theme={null}
NSUserGroup GetUserGroup()
```

**Returns:** [CRMScript.NetServer.NSUserGroup](CRMScript.NetServer.NSUserGroup) - The main user group that this user belongs to.

**Example:**

```crmscript theme={null}
NSUser thing;
NSUserGroup userGroup = thing.GetUserGroup();
```

## GetUserName()

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

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - User name, a.k.a. Login name. This might be an email address.

**Example:**

```crmscript theme={null}
NSUser thing;
String userName = thing.GetUserName();
```

## GetWaitingForApproval()

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

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - The user is waiting for an administrator to approve/grant her/him access.

**Example:**

```crmscript theme={null}
NSUser thing;
Bool waitingForApproval = thing.GetWaitingForApproval();
```

## SetAssociateId(Integer)

```crmscript theme={null}
Void SetAssociateId(Integer associateId)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
Integer associateId;
thing.SetAssociateId(associateId);
```

## SetCredentials(NSCredential\[])

```crmscript theme={null}
Void SetCredentials(NSCredential[] credentials)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
NSCredential[] credentials;
thing.SetCredentials(credentials);
```

## SetCustomFields(Map)

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

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

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

**Example:**

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

## SetDeleted(Bool)

```crmscript theme={null}
Void SetDeleted(Bool deleted)
```

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

## SetEjUserId(Integer)

```crmscript theme={null}
Void SetEjUserId(Integer ejUserId)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
Integer ejUserId;
thing.SetEjUserId(ejUserId);
```

## SetExtraFields(Map)

Sets the extra field values on User with a map.

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

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

**Example:**

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

## SetIsOnTravel(Bool)

```crmscript theme={null}
Void SetIsOnTravel(Bool isOnTravel)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
Bool isOnTravel;
thing.SetIsOnTravel(isOnTravel);
```

## SetIsPersonRetired(Bool)

```crmscript theme={null}
Void SetIsPersonRetired(Bool isPersonRetired)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
Bool isPersonRetired;
thing.SetIsPersonRetired(isPersonRetired);
```

## SetLastlogin(DateTime)

```crmscript theme={null}
Void SetLastlogin(DateTime lastlogin)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
DateTime lastlogin;
thing.SetLastlogin(lastlogin);
```

## SetLastlogout(DateTime)

```crmscript theme={null}
Void SetLastlogout(DateTime lastlogout)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
DateTime lastlogout;
thing.SetLastlogout(lastlogout);
```

## SetLicenseOwners(NSLicenseOwner\[])

```crmscript theme={null}
Void SetLicenseOwners(NSLicenseOwner[] licenseOwners)
```

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

<Note>
  These module licenses are either assigned or unassigned to this user
</Note>

**Example:**

```crmscript theme={null}
NSUser thing;
NSLicenseOwner[] licenseOwners;
thing.SetLicenseOwners(licenseOwners);
```

## SetName(String)

```crmscript theme={null}
Void SetName(String name)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
String name;
thing.SetName(name);
```

## SetNickName(String)

```crmscript theme={null}
Void SetNickName(String nickName)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
String nickName;
thing.SetNickName(nickName);
```

## SetOtherGroups(NSUserGroup\[])

```crmscript theme={null}
Void SetOtherGroups(NSUserGroup[] otherGroups)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
NSUserGroup[] otherGroups;
thing.SetOtherGroups(otherGroups);
```

## SetPerson(NSPerson)

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

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

**Example:**

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

## SetRank(Integer)

```crmscript theme={null}
Void SetRank(Integer rank)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
Integer rank;
thing.SetRank(rank);
```

## SetRequestSignature(String)

```crmscript theme={null}
Void SetRequestSignature(String requestSignature)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
String requestSignature;
thing.SetRequestSignature(requestSignature);
```

## SetRole(NSRole)

```crmscript theme={null}
Void SetRole(NSRole role)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
NSRole role;
thing.SetRole(role);
```

## SetTicketCategories(NSMDOListItem\[])

```crmscript theme={null}
Void SetTicketCategories(NSMDOListItem[] ticketCategories)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
NSMDOListItem[] ticketCategories;
thing.SetTicketCategories(ticketCategories);
```

## SetTooltip(String)

```crmscript theme={null}
Void SetTooltip(String tooltip)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
String tooltip;
thing.SetTooltip(tooltip);
```

## SetType(Integer)

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

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

**Example:**

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

## SetUserGroup(NSUserGroup)

```crmscript theme={null}
Void SetUserGroup(NSUserGroup userGroup)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
NSUserGroup userGroup;
thing.SetUserGroup(userGroup);
```

## SetUserName(String)

```crmscript theme={null}
Void SetUserName(String userName)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
String userName;
thing.SetUserName(userName);
```

## SetWaitingForApproval(Bool)

```crmscript theme={null}
Void SetWaitingForApproval(Bool waitingForApproval)
```

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

**Example:**

```crmscript theme={null}
NSUser thing;
Bool waitingForApproval;
thing.SetWaitingForApproval(waitingForApproval);
```


## Related topics

- [NSUserAgent](/en/automation/crmscript/reference/CRMScript.NetServer.NSUserAgent.md)
- [NSUserGroup](/en/automation/crmscript/reference/CRMScript.NetServer.NSUserGroup.md)
- [NSUserInfo](/en/automation/crmscript/reference/CRMScript.NetServer.NSUserInfo.md)
