Class: UserContext

documents.sdk UserContext

Constructors

The UserContext provides access to information related to the current system user like the used language, login name,
accessProfiles and custom properties.

Properties:
Name Type Description
absent Boolean

The state of absence. True if the system user is absent, false otherwise.

accessProfiles Array.<String>

All technical access profile names of the system user, e.g. ["Administration", "Service", "Warehouse", "Employee"].

dateFormatPattern String

The date format pattern of the current system user language according to ISO 8601, e.g. "dd.MM.yyyy" or "MM/dd/yyyy".
In DOCUMENTS Manager, the date format setting is defined at "Documents Settings" / "Locale/Format" / "Locale n" / "Date format".

eMail String

The business email address of the system user.

fax String

The business fax number of the system user.

firstName String

The first name of the system user.

fullName String

The full name of the system user, i.e. the concatenation of the first name and the last name.

language String

The current language of the system user according to ISO 639-1 (two-letter codes), e.g. "de", "en" or "fr".

lastName String

The last name of the system user.

login String

The login name of the system user.

mobile String

The business mobile number of the system user.

numberFormatDecimalSeparator String

The decimal separator of the current system user language, e.g. "," or ".".
In DOCUMENTS Manager, the decimal separator character setting is defined at "Documents Settings" / "Locale/Format" / "Locale n" / "Decimal point".

numberFormatGroupingSeparator String

The thousands grouping separator of the current system user language, e.g. ".", "," or "'".
In DOCUMENTS Manager, the grouping separator character setting is defined at "Documents Settings" / "Properties" / "groupingNumeric<language>" while "Documents Settings" / "Properties" / "groupingNumeric" has to be set to "1".

principal String

The principal name of the system user, e.g. "dopaag".

salutation String

The DOCUMENTS Manager value of "title" of the system user.

sex String

The DOCUMENTS Manager value of "salutation" of the system user.

telephone String

The business telephone number of the system user.

  • Since:
    • 5.0a

Methods

getCustomPropertyValue(name, type){String}

Returns a custom user property value by its name and type.
Custom user properties can be used to persist (i.e. load and store) arbitrary, user related application data across user sessions. The data type has to be String, e.g. JSON, XML or plain text data.

In DOCUMENTS Manager, any custom user property can be found at the lower properties tab of the user account settings dialog.

Notice that this function performs a request against the application server which is called synchronous by default. Thus the JavaScript- and UI thread of the browser will be blocked until the server response has returned.

Name Type Description
name String

the name of the property

type String

the type of the property

Returns:
Type Description
String the value of the property
Examples
//  JSON example
//  Note: the custom user property "worldJSON" is stored in the corresponding setCustomPropertyValue() example
var worldJSON = documentsContext.getUserContext().getCustomPropertyValue("worldJSON", "");
console.log(worldJSON);  //  -> "{"Asia" : ["China", "India", "Japan"], "Europe" : ["Austria", "Denmark", "Germany", "Great Britain", "Norway", "Sweden", ...}"
var worldMap = JSON.parse(worldJSON);
var continent = worldMap["Oceania"];

for(var i = 0; i < continent.length; i++) {
	console.log(continent[i]);  //  -> "Australia", "New Zealand"
}
// XML example
// Note: the custom user property "worldXML" is stored in the corresponding setCustomPropertyValue() example
var worldXML = documentsContext.getUserContext().getCustomPropertyValue("worldXML", "");
console.log(worldXML);  // -> "<World><Continent name="Asia"><Country>China</Country><Country>India</Country><Country>Japan</Country></Continent><Continent name="Europe"><Country>Austria</Country>..."
var parser = new DOMParser();
var worldNode = parser.parseFromString(worldXML, "application/xml");
var countryNodes = worldNode.querySelectorAll("Continent[name='Oceania'] Country");

for(var i = 0; i < countryNodes.length; i++) {
	console.log(countryNodes[i].textContent);  //  -> "Australia", "New Zealand"
}

getProperty(key){String}

Returns a system user property by its key.
User properties can be used to define arbitrary, user related application settings. They are read-only by default. The data type has to be String, e.g. JSON, XML or plain text data.

In DOCUMENTS Manager, any user property can be found at the upper properties tab of the user account settings dialog.

Notice that this function performs a request against the application server which is called synchronous by default. Thus the JavaScript- and UI thread of the browser will be blocked until the server response has returned.

Name Type Description
key String

the key of the property

  • Since:
    • 5.0a
Returns:
Type Description
String the value of the property
Example
var userContext = documentsContext.getUserContext();
var b0 = userContext.getProperty("color") || "blue";  //  type: String, default "blue"
var b1 = userContext.getProperty("availableOnWeekends") === "true";  //  type: boolean, default: false
var b2 = userContext.getProperty("availableDuringWeek") !== "false";  //  type: boolean, default: true
var b3 = parseInt(userContext.getProperty("hoursPerWeek"), 10) || 25;  // type: Number (Integer), default: 25

removeCustomProperty(name, type){String}

Removes a custom user property by its name and type and returns its previous value.
Custom user properties can be used to persist (i.e. load and store) arbitrary, user related application data across user sessions. The data type has to be String, e.g. JSON, XML or plain text data.

In DOCUMENTS Manager, any custom user property can be found at the lower properties tab of the user account settings dialog.

Notice that this function performs a request against the application server which is called synchronous by default. Thus the JavaScript- and UI thread of the browser will be blocked until the server response has returned.

Name Type Description
name String

the name of the property

type String

the type of the property

Returns:
Type Description
String the value of the property previous to removal
Examples
documentsContext.getUserContext().removeCustomProperty("worldXML", "");
documentsContext.getUserContext().removeCustomProperty("pdfViewerUserProperty", "json");

setCustomPropertyValue(name, type, value){String}

Sets a custom user property value by its name and type.
Custom user properties can be used to persist (i.e. load and store) arbitrary, user related application data across user sessions. The data type has to be String, e.g. JSON, XML or plain text data.

In DOCUMENTS Manager, any custom user property can be found at the lower properties tab of the user account settings dialog.

Notice that this function performs a request against the application server which is called synchronous by default. Thus the JavaScript- and UI thread of the browser will be blocked until the server response has returned.

Name Type Description
name String

the name of the property

type String

the type of the property

value String

the new value of the property

Returns:
Type Description
String the previous value of the property
Examples
//  JSON example
//  Note: the custom user property "worldJSON" is read in the corresponding getCustomPropertyValue() example
var worldMap = {
	"Asia" : ["China", "India", "Japan"],
	"Europe" : ["Austria", "Denmark", "Germany", "Great Britain", "Norway", "Sweden", "Switzerland"],
	"Oceania" : ["Australia", "New Zealand"],
	"South America" : ["Argentina", "Brazil", "Chile", "Peru", "Venezuela"]
}

var worldJSON = JSON.stringify(worldMap);
console.log(worldJSON);  //  -> "{"Asia" : ["China", "India", "Japan"], "Europe" : ["Austria", "Denmark", "Germany", "Great Britain", "Norway", "Sweden", ...}"

documentsContext.getUserContext().setCustomPropertyValue("worldJSON", "", worldJSON);
//  XML example
//  Note: the custom user property "worldXML" is read in the corresponding getCustomPropertyValue() example
var worldMap = {
	"Asia" : ["China", "India", "Japan"],
	"Europe" : ["Austria", "Denmark", "Germany", "Great Britain", "Norway", "Sweden", "Switzerland"],
	"Oceania" : ["Australia", "New Zealand"],
	"South America" : ["Argentina", "Brazil", "Chile", "Peru", "Venezuela"]
}

var createContinent = function(worldNode, continent, countries) {
 var continentNode = document.createElementNS("", 'Continent');
     continentNode.setAttribute('name', continent);
     worldNode.appendChild(continentNode);

 createCountries(continentNode, countries);
}

var createCountries = function(continentNode, countries) {
	for(var i = 0; i < countries.length; i++) {
		var countryNode = document.createElementNS("", 'Country');
		countryNode.appendChild( document.createTextNode(countries[i]) );
		continentNode.appendChild(countryNode);
	}
}

var worldNode = document.createElementNS("", "World");

for(continent in worldMap) {
	createContinent(worldNode, continent, worldMap[continent]);
}

var serializer = new XMLSerializer();
var worldXML = serializer.serializeToString(worldNode);
console.log(worldXML);  // -> "<World><Continent name="Asia"><Country>China</Country><Country>India</Country><Country>Japan</Country></Continent><Continent name="Europe"><Country>Austria</Country>..."

documentsContext.getUserContext().setCustomPropertyValue("worldXML", "", worldXML);