Table of Contents

Class UserSession

Namespace
Sage.CRM.Utils
Assembly
SageCRMNet.dll

A class to hold information on the currently logged on user. It also provides methods for date and time formatting using the users preferences and other useful options.

public class UserSession
Inheritance
UserSession
Inherited Members

Properties

this[UserOptions]

Gets or sets the value of the current users preference for various options.

public string this[UserOptions fieldName] { get; set; }

Parameters

fieldName UserOptions

The name of the preference option - use Sage.UserOptions for full list of available options ParamNames.

Property Value

string

The value of that option.

this[string]

Get or set the value of the current users preference for various options.

public string this[string fieldName] { get; set; }

Parameters

fieldName string

The name of the preference option.

Property Value

string

The value of that option.

Logon

The logon name of the current user (readonly).

public string Logon { get; }

Property Value

string

TeamId

The Team ID of the current user (readonly).

public int TeamId { get; }

Property Value

int

TeamName

The Team name of the current user (readonly).

public string TeamName { get; }

Property Value

string

Teams

Return the Teams of the current user.

public List<string> Teams { get; }

Property Value

List<string>

TerritoryId

The Primary Territory ID of the current user (readonly).

public double TerritoryId { get; }

Property Value

double

UserEmailAddress

The email address of the current user (readonly).

public string UserEmailAddress { get; }

Property Value

string

UserId

The ID of the current user from the user's table (readonly).

public int UserId { get; }

Property Value

int

UserLanguage

The language code for the current user (readonly).

public string UserLanguage { get; }

Property Value

string

UserName

The current user's full name (First Name + Last Name) (readonly).

public string UserName { get; }

Property Value

string

UserPhone

The current user's phone number (readonly).

public string UserPhone { get; }

Property Value

string

Methods

HasInfoAdminRight(InfoAdminRights)

Check if the user has various "Info Admin" rights. String constants for these rights are declared in Sage.InfoAdminRights.

public bool HasInfoAdminRight(InfoAdminRights infoAdminRight)

Parameters

infoAdminRight InfoAdminRights

Returns

bool

HasRights(PermissionType, string)

Check if the current user has access rights to a given table.

public bool HasRights(PermissionType perType, string tableName)

Parameters

perType PermissionType

The Permission Type. Can be Insert/Update/Delete see Sage.PermissionType for details.

tableName string

The table to check, must be a primary table.

Returns

bool

IsAdmin()

Check if the current user has Admin Rights.

public bool IsAdmin()

Returns

bool

True if the user has admin rights.

IsInfoAdmin()

Returns true if the user has "Info Admin" rights.

public bool IsInfoAdmin()

Returns

bool

IsInRange(PermissionType, string, int, int, int, int)

Check whether a specific record is within a users security view for the given permission type.

public bool IsInRange(PermissionType perType, string tableName, int territoryId, int userId, int teamId, int createdByUserId)

Parameters

perType PermissionType

Permission type to check eg Edit/Insert/Delete see Sage.PermissionType for details.

tableName string

Tablename, must be a primary entity.

territoryId int

Territory ID of the record.

userId int

Assiged to user of the record.

teamId int

Team ID of the record.

createdByUserId int

Created by user of the record.

Returns

bool

SessionRead(string)

Returns one object added to the user session.

public object SessionRead(string key)

Parameters

key string

Returns

object

SessionWrite(string, object)

Write a value to the user session.

public void SessionWrite(string key, object value)

Parameters

key string

Key Name.

value object

Object Value.

Remarks

Complex objects like class needs to be serialized before adding to the user session and deserialized later.

VirtualImgPath()

Path to images to be used in HTML pages. For example /crm62/Themes/img/default/. The path must always end with '/'.

public string VirtualImgPath()

Returns

string