DOCUMENTS 5 - PortalScripting API
|
The Context class is the basic anchor for the most important attributes and methods to customize DOCUMENTS through PortalScripting. More...
Public Member Functions | |
CustomProperty | addCustomProperty (String name, String type, String value) |
Creates a new global custom property. More... | |
Date | addTimeInterval (Date ts, number amount, String unit='minutes', boolean useWorkCalendar=true) |
Adds a time interval to a Date object. More... | |
boolean | changeScriptUser (String login) |
Change the user context of the PortalScript. More... | |
boolean | clearEnumvalCache (String scriptName) |
Clears the cached enumval at the specified PortalScript. More... | |
String | convertDateToString (Date dateOrTimeStamp, String locale=user locale) |
Convert a Date object representing a date into a String. More... | |
String | convertNumericToString (number value, String decimalSep, String thousandSep, number precision=2) |
Converts a Number into a formatted String. More... | |
String | convertNumericToString (number value, String locale=user locale, number precision=2) |
Converts a Number into a formatted String. More... | |
Date | convertStringToDate (String dateOrTimeStamp, String locale) |
Convert a String representing a date into a Date object. More... | |
float | convertStringToNumeric (String numericValue, String decimalSep, String thousandSep) |
Converts a formated String into a number. More... | |
float | convertStringToNumeric (String numericValue, String locale=userlocale) |
Converts a formated String into a number. More... | |
int | countPoolFiles (String fileType) |
Retrieve the amount of pool files of the specified filetype in the system. More... | |
AccessProfile | createAccessProfile (String profileName) |
Create a new access profile in the DOCUMENTS environment. More... | |
ArchiveServer | createArchiveServer (String name, String type) |
Create a new ArchiveServer. More... | |
SystemUser | createFellow (String loginName, boolean isDlcUser, String licenseType='named') |
Create a new fellow in the DOCUMENTS environment. More... | |
DocFile | createFile (String fileType) |
Create a new file of the specified filetype. More... | |
Folder | createFolder (String name, String type) |
Create a new folder of the specified type on the top level. More... | |
boolean | createPoolFile (String fileType) |
Create a new pool file of the specified filetype. More... | |
SystemUser | createSystemUser (String loginName, boolean isDlcUser, String licenseType='named') |
Create a new user in the DOCUMENTS environment. More... | |
boolean | deleteAccessProfile (String profileName) |
Delete a certain access profile in the DOCUMENTS environment. More... | |
boolean | deleteFolder (Folder folderObj) |
Delete a folder in DOCUMENTS. More... | |
boolean | deleteSystemUser (String loginName) |
Delete a user in the DOCUMENTS environment. More... | |
string | doMaintenance (String operationName) |
Calls the specified maintenance operation. More... | |
void | enableModules (Object root=undefined) |
Allow dynamic imports of other scripts as modules. More... | |
number | extCall (String workDir, String cmd, boolean synced) |
Perform an external command shell call on the Portalserver. More... | |
string [] | extProcess (String cmd) |
Perform an external process call on the Portalserver and returns the exitcode of the external process and the standard output. More... | |
AccessProfile | findAccessProfile (String profileName) |
Find a certain access profile in the DOCUMENTS environment. More... | |
CustomPropertyIterator | findCustomProperties (String filter) |
Searches for CustomProperties. More... | |
SystemUser | findSystemUser (String login) |
Retrieve a user by his/her login. More... | |
SystemUser | findSystemUserByAlias (String alias) |
Retrieve a user by an alias name. More... | |
AccessProfileIterator | getAccessProfiles (boolean includeInvisibleProfiles=false) |
Get an iterator with all access profiles of in the DOCUMENTS environment. More... | |
ArchiveConnection | getArchiveConnection (String archiveServerName) |
Get an ArchiveConnection object. More... | |
DocFile | getArchiveFile (String key) |
Get a file from the archive. More... | |
ArchiveServer | getArchiveServer (String name) |
Get an ArchiveServer identified by its name. More... | |
ArchiveServerIterator | getArchiveServers () |
Get an iterator with all ArchiveServers in the DOCUMENTS environment. More... | |
String | getAutoText (String autoText) |
Get the String value of a DOCUMENTS autotext. More... | |
String | getClientLang () |
Get the abbreviation of the current user's portal language. More... | |
int | getClientSystemLang () |
Get the script's execution context portal language index. More... | |
String | getClientType () |
Get the connection info of the client connection. More... | |
String | getCurrentUserAttribute (String attributeName) |
Get the String value of an attribute of the current user. More... | |
CustomPropertyIterator | getCustomProperties (String nameFilter="", String typeFilter="") |
Get a CustomPropertyIterator with global custom properties. More... | |
number | getDatesDiff (Date earlierDate, Date laterDate, String unit='days', boolean useWorkCalendar=true) |
Subtract two Date objects to get their difference. More... | |
Document | getDocumentById (String idFile, String idDocument) |
Get the Document by its unique file-id. More... | |
string [] | getEnumAutoText (String autoText) |
Get an array with the values of an enumeration autotext. More... | |
String | getEnumErgValue (String fileType, String field, String techEnumValue, String locale="") |
Get the ergonomic label of a multilanguage enumeration list value. More... | |
String | getEnumValues (String fileType, String field) |
Get an array with enumeration list entries. More... | |
String | getFieldErgName (String fileType, String field, String locale="") |
Get the ergonomic label of a file field. More... | |
DocFile | getFileById (String idFile) |
Get the file by its unique file-id. More... | |
String | getFileTypeErgName (String fileType, String locale="") |
Get the ergonomic label of a filetype. More... | |
String | getFileTypeOID (String nameFiletype, boolean oidLow=false) |
Returns the object-id of a filetype. More... | |
int | getFolderPosition (Folder folder) |
Retrieve the position of a top level folder in the global context. More... | |
FolderIterator | getFoldersByName (String folderPattern, String type="") |
Retrieve a list of folders with identical name. More... | |
String | getFromSystemTable (String identifier) |
Retrieve the desired entry of the system messages table. More... | |
object | getJSObject (String oid) |
Get a JS_Object by object id. More... | |
String | getLastError () |
Function to get the description of the last error that occurred. More... | |
String | getLocaleValue (String value, String locale="") |
Get the value/label of a String with the format "de:rot;en:red;fr:rouge" in the current or defined portal language. More... | |
String | getPrincipalAttribute (String attributeName) |
Get the String value of an attribute of the DOCUMENTS principal. More... | |
Float | getProgressBar () |
Gets the current progress value in % of the progress bar in the Documents-Manager during the PortalScript execution. More... | |
DocQueryParams | getQueryParams () |
Get the actual search parameters within an "OnSearch" or "FillSearchScript" exit. More... | |
String | getRegisterErgName (String fileTypeName, String registerName, String locale="") |
Get the ergonomic label of a register. More... | |
String | getServerInstallPath () |
Create a String containing the installation path of the portal server. More... | |
SystemUser | getSystemUser () |
Get the current user as a SystemUser object. More... | |
SystemUserIterator | getSystemUsers (boolean includeLockedUsers=false) |
Get a list of all users created in the system. More... | |
String | getTempPathByToken (String accessToken, boolean dropToken=true) |
Returns the temporary server path, that was ordered by the gadget API for the token. More... | |
String | getTmpFilePath () |
Create a String containing a complete path and filename to a temporary file. More... | |
ArchiveConnection | getXMLServer (String archiveServerName="") |
Get an ArchiveConnection object. More... | |
Boolean | hasPEMModule (Integer moduleConst) |
Function to check if a module is licenced in the pem. More... | |
boolean | reloadCurrentPrincipal (boolean pemReload=false) |
Reloads the current principal. More... | |
boolean | reloadPrincipal (String principalName, boolean pemReload=false) |
Reloads the desired principal. More... | |
String | sendTCPStringRequest (String server, int port, String request, int responseTimeout=3000) |
Send a String as TCP-Request to a server. More... | |
String | setClientLang (String locale) |
Set the abbreviation of the current user's portal language. More... | |
boolean | setClientSystemLang (int langIndex) |
Set the script's execution context portal language to the desired language. More... | |
boolean | setFolderPosition (Folder folder, int position) |
Place a top level folder a at given position in the global context. More... | |
CustomProperty | setOrAddCustomProperty (String name, String type, String value) |
Creates or modifies a global custom property according the name and type. More... | |
boolean | setPrincipalAttribute (String attributeName, String value) |
Set an attribute of the DOCUMENTS principal to the desired value. More... | |
void | setProgressBar (float value) |
Sets the progress (%) of the progress bar in the Documents-Manager during the PortalScript execution. More... | |
void | setProgressBarText (String text) |
Sets the progress bar text in the Documents-Manager during the PortalScript execution. More... | |
boolean | writeLogBook (int actionCode, String detail1, String detail2, String detail3) |
Logs an executed action to the logbook. More... | |
Public Attributes | |
String | clientId |
Id of the client / thread which is the execution context of the script. More... | |
String | currentUser |
Login of the user who has triggered the script execution. More... | |
Document | document |
Document object representing the current document that the script is executed at. More... | |
String | errorMessage |
Error message text to be returned by the script. More... | |
String | event |
Event which triggered the script execution. More... | |
String | fieldName |
Returns in an enumeration script the name of the field where the script is executed for. More... | |
DocFile | file |
DocFile object representing the current file that the script is executed at. More... | |
String | fileType |
Technical name of the filetype of the file which is the execution context of the script. More... | |
Folder | folder |
Current folder in which context the script is running. More... | |
FileResultset | folderFiles |
FileResultset with all files of a folder. More... | |
String | folderName |
Technical name of the folder the script is called from. More... | |
String | qsession |
Session id of the current query-session. More... | |
Register | register |
Register object representing the current register that the script is executed at. More... | |
String | returnType |
Type of the return value that the script returns. More... | |
String | scriptName |
Name of the executed script. More... | |
ArchiveFileResultset | selectedArchiveFiles |
Iterator with the selected archive files of a folder. More... | |
string [] | selectedArchiveKeys |
Array with the keys of the selected archive files of a folder. More... | |
DocumentIterator | selectedDocuments |
DocumentIterator with the selected Documents (attachments) of the current document register. More... | |
FileResultset | selectedFiles |
Iterator with the selected files of a folder. More... | |
String | sourceCode |
Script source code of the script after including other scripts by the #import rule. More... | |
String | workflowActionId |
Id of the locking WorkflowStep for the user for the current file. More... | |
String | workflowActionName |
Name of the locking WorkflowStep for the user for the current file. More... | |
String | workflowControlFlowId |
Id of the ControlFlow the current file currently passes. More... | |
String | workflowControlFlowName |
Name of the ControlFlow the current file currently passes. More... | |
WorkflowStep | workflowStep |
Returns the current workflowstep if the script is run in context of a workflow. More... | |
PEM Module Constants | |
These constants build an enumeration of the possible values of the pem license.
| |
Integer | PEM_MODULE_INVOICE |
Integer | PEM_MODULE_FP_HENR |
Integer | PEM_MODULE_LDAP |
Integer | PEM_MODULE_CONTRACT |
Integer | PEM_MODULE_OUTLOOK_WEB |
Integer | PEM_MODULE_OUTLOOK_SYNC |
Integer | PEM_MODULE_WORDML |
Integer | PEM_MODULE_MOBILE |
Integer | PEM_MODULE_BUSINESS_UNITS |
Integer | PEM_MODULE_CONTROLLING |
Integer | PEM_MODULE_REPORTING |
Integer | PEM_MODULE_EASYHR |
Integer | PEM_MODULE_CONTRACT_SAP |
Integer | PEM_MODULE_GADGETS |
Integer | PEM_MODULE_INBOX |
Integer | PEM_MODULE_IMS |
Integer | PEM_MODULE_CGC |
Integer | PEM_MODULE_CGC_ENT |
Integer | PEM_MODULE_CGC_ENT_PLUS |
Integer | PEM_MODULE_CREATOR |
Integer | PEM_MODULE_DOC_TREE |
Integer | PEM_MODULE_RISK_MANAGEMENT |
Integer | PEM_MODULE_IFRS16 |
Integer | PEM_MODULE_SIGN |
Integer | PEM_MODULE_IP_MANAGEMENT |
The Context class is the basic anchor for the most important attributes and methods to customize DOCUMENTS through PortalScripting.
There is exactly ONE implicit object of the class Context
which is named context
. The implicit object context
is the root object in any script. With the context
object you are able to access to the different DOCUMENTS objects like DocFile, Folder etc. Some of the attributes are only available under certain conditions. It depends on the execution context of the PortalScript, whether a certain attribute is accessible or not. For example, context.selectedFiles
is available in a folder userdefined action script, but not in a script used as a signal exit.
Context
, since the context
object is always available. CustomProperty Context::addCustomProperty | ( | String | name, |
String | type, | ||
String | value | ||
) |
Creates a new global custom property.
name | String value defining the name |
type | String value defining the type |
value | String value defining the value |
Date Context::addTimeInterval | ( | Date | ts, |
number | amount, | ||
String | unit = 'minutes' , |
||
boolean | useWorkCalendar = true |
||
) |
Adds a time interval to a Date object.
Since date manipulation in Javascript is odd sometimes, this useful function allows to conveniently add a given period of time to a given date, e.g. to calculate a due date based upon the current date plus xx
days
ts | Date object to which the period of time should be added |
amount | integer value of the period of time to be added |
unit | String value representing the time unit of the period of time. You may use one of the following unit values:
|
useWorkCalendar | true if work calendar should be taken into account, false if not. The work calendar has to be defined at Documents->Settings |
boolean Context::changeScriptUser | ( | String | login | ) |
Change the user context of the PortalScript.
In some cases, especially if you make heavy use of access privileges both with files and file fields, it might be neccessary to run a script in a different user context than the user who triggered the script execution. For example, if the current user is not allowed to change any field values, a PortalScript running in this user's context will fail, if it tries to change a field value. In this case it is best practice to switch the user context to some superuser who is allowed to perform the restricted action before that restricted action is executed. You may change the script's user context as often as you need, a change only applies to the instructions following the changeScriptUser() call.
login | String value containing the login name of the user to switch to |
true
if successful, false
in case of any error boolean Context::clearEnumvalCache | ( | String | scriptName | ) |
Clears the cached enumval at the specified PortalScript.
scriptName | String with the name of the PortalScript |
true
if successful, false
in case of any error. String Context::convertDateToString | ( | Date | dateOrTimeStamp, |
String | locale = user locale |
||
) |
Convert a Date object representing a date into a String.
The output String is in the date format of the specified locale. If you leave the locale parameter away the current locale of the script context will be used.
dateOrTimeStamp | Date/Timestamp object representing the desired date |
[locale] | Locale as String (default = user locale) |
String Context::convertNumericToString | ( | number | value, |
String | decimalSep, | ||
String | thousandSep, | ||
number | precision = 2 |
||
) |
Converts a Number into a formatted String.
The output String may have any format you like. The following parameters defines the format to configure the fromat of the numeric String.
value | Numeric object representing the number |
decimalSep | Decimal-Separator as String |
thousandSep | Thousend-Separator as String |
precision | Precision as number (default=2) |
String Context::convertNumericToString | ( | number | value, |
String | locale = user locale , |
||
number | precision = 2 |
||
) |
Converts a Number into a formatted String.
The output String is formatted like the definition in the locale. If the locale is not defined by parameter, the locale of the current user will be used.
value | Numeric object representing the number |
locale | Locale as String |
[precision] | Precision as number (default=2) |
Date Context::convertStringToDate | ( | String | dateOrTimeStamp, |
String | locale | ||
) |
Convert a String representing a date into a Date object.
The output Date is in the date format of the specified locale. If you omit the locale parameter the current locale of the script context will be used.
dateOrTimeStamp | String representing a date has to be formatted as the definition in the specified locale, e.g. "TT.MM.JJJJ" for the locale "de". |
locale | Optional String value with the locale abbreviation (according to the principal's configuration). |
float Context::convertStringToNumeric | ( | String | numericValue, |
String | decimalSep, | ||
String | thousandSep | ||
) |
Converts a formated String into a number.
The input String may have any format you like. The following parameters defines the format to configure the format of the numeric String.
numericValue | Formatted numeric String |
decimalSep | Decimal-Separator as String |
thousandSep | Thousend-Separator as String |
float Context::convertStringToNumeric | ( | String | numericValue, |
String | locale = userlocale |
||
) |
Converts a formated String into a number.
The input String has to be formatted like the definition in the locale. If the locale is not defined by parameter, the locale of the current user will be used.
numericValue | Formatted numeric String |
locale | Locale as String |
int Context::countPoolFiles | ( | String | fileType | ) |
Retrieve the amount of pool files of the specified filetype in the system.
fileType | the technical name of the desired filetype |
AccessProfile Context::createAccessProfile | ( | String | profileName | ) |
Create a new access profile in the DOCUMENTS environment.
If the access profile already exist, the method returns an error.
profileName | technical name of the access profile |
null
in case of any error ArchiveServer Context::createArchiveServer | ( | String | name, |
String | type | ||
) |
Create a new ArchiveServer.
This function creates a new ArchiveServer for the specified archive software on the top level. These types are available:
EEI
EEX_native
EBIS_store
NOAH
None
name | The technical name of the ArchiveServer to be created. |
type | The desired archive software of the ArchiveServer. |
null
if failed. SystemUser Context::createFellow | ( | String | loginName, |
boolean | isDlcUser, | ||
String | licenseType = 'named' |
||
) |
Create a new fellow in the DOCUMENTS environment.
loginName | login of the fellow |
isDlcUser | automatically grant DOCUMENTS access (true/false) |
licenseType | optional definition of the license type for that user (allowed values are "named" , "concurrent_standard" , "concurrent_open" and "shared" (deprecated: "concurrent" ) |
null
"shared"
is only available for pure archive retrieval users. It is not possible to create a shared user with DOCUMENTS access! "concurrent_standard"
, "concurrent_open"
)DocFile Context::createFile | ( | String | fileType | ) |
Create a new file of the specified filetype.
This function creates a new file of the given filetype. Since the script is executed in the context of a particular user, it is mandatory that user possesses sufficient access privileges to create new instances of the desired filetype, otherwise the method will fail.
If an error occurs during creation of the file the return value will be null
and you can access an error message describing the error with getLastError().
fileType | Name of the filetype |
null
if failed. Folder Context::createFolder | ( | String | name, |
String | type | ||
) |
Create a new folder of the specified type on the top level.
This function creates a new folder of the specified type on the top level. There are three types available:
public
dynamicpublic
onlysubfolder
name | The technical name of the folder to be created. |
type | The desired type of the folder. |
null
if failed. boolean Context::createPoolFile | ( | String | fileType | ) |
Create a new pool file of the specified filetype.
The script must run in the context of a user who has sufficient access privileges to create new files of the specified filetype, otherwise this method will fail.
fileType | the technical name of the desired filetype |
true
if successful, false
in case of any error SystemUser Context::createSystemUser | ( | String | loginName, |
boolean | isDlcUser, | ||
String | licenseType = 'named' |
||
) |
Create a new user in the DOCUMENTS environment.
loginName | login of the user |
isDlcUser | automatically grant DOCUMENTS access (true/false) |
licenseType | optional definition of the license type for that user (allowed values are "named" , "concurrent" and "shared" ) |
null
"shared"
is only available for pure archive retrieval users. It is not possible to create a shared user with DOCUMENTS access! "concurrent_standard"
, "concurrent_open"
)boolean Context::deleteAccessProfile | ( | String | profileName | ) |
Delete a certain access profile in the DOCUMENTS environment.
profileName | technical name of the access profile |
true
in case of successful deletion, false
in case of any error boolean Context::deleteFolder | ( | Folder | folderObj | ) |
Delete a folder in DOCUMENTS.
folderObj | an object of the Class Folder which represents the according folder in DOCUMENTS |
true
if successful, false
in case of any error boolean Context::deleteSystemUser | ( | String | loginName | ) |
Delete a user in the DOCUMENTS environment.
loginName | login of the user |
true
if the deletion was successful, false
in case of any error string Context::doMaintenance | ( | String | operationName | ) |
Calls the specified maintenance operation.
operationName | String with the name of the maintenance operation |
String
with the return message of the of the maintenance operation. void Context::enableModules | ( | Object | root = undefined | ) |
Allow dynamic imports of other scripts as modules.
This function defines a function named require()
, either in a passed object or in the global scope of the calling script. In sequence require
('<scriptname>') can be used to import other portal scripts, which are implemented in the style of Node.js modules.
root | An optional Object to define the require() function as a property. Use this parameter, if the name "require" is already reserved in the script's global namespace. |
require()
always see the function as a global parameter. DOCUMENTS exposes a generic 'module' and an initially empty 'exports' object to each imported script. Other features of the module concept of Node.js are not available. number Context::extCall | ( | String | workDir, |
String | cmd, | ||
boolean | synced | ||
) |
Perform an external command shell call on the Portalserver.
In the context of a work directory, an external command shell call is executed, usually a batch file. You can decide whether the scripting engine must wait for the external call to complete or whether the script execution continues asynchonously. If the script waits for the external call to complete, this method returns the errorcode of the external call as an integer value.
workDir | String containing a complete directory path which should be used as the working directory |
cmd | String containing the full path and filename to the batch file which shall be executed |
synced | boolean value which defines whether the script must wait for the external call to finish (true ) or not (false ) |
string [] Context::extProcess | ( | String | cmd | ) |
Perform an external process call on the Portalserver and returns the exitcode of the external process and the standard output.
An external process call is executed, e.g. a batch file. The methods returns an array of the size 2. The first array value is the exit code of the external process. The second array value contains the content that the external process has written to the standard output.
cmd | String containing the full path and filename to the program which shall be executed |
AccessProfile Context::findAccessProfile | ( | String | profileName | ) |
Find a certain access profile in the DOCUMENTS environment.
profileName | technical name of the access profile |
null
in case of any error CustomPropertyIterator Context::findCustomProperties | ( | String | filter | ) |
Searches for CustomProperties.
filter | Optional String value defining the search filter (specification see example) |
SystemUser Context::findSystemUser | ( | String | login | ) |
Retrieve a user by his/her login.
If the user does not exist, then the return value will be null
.
login | name of the user |
SystemUser Context::findSystemUserByAlias | ( | String | alias | ) |
Retrieve a user by an alias name.
If the alias does not exist or is not connected to a user then the return value will be null
.
alias | technical name of the desired alias |
AccessProfileIterator Context::getAccessProfiles | ( | boolean | includeInvisibleProfiles = false | ) |
Get an iterator with all access profiles of in the DOCUMENTS environment.
includeInvisibleProfiles | optional boolean value to define, if access profiles that are not checkmarked as being visible in DOCUMENTS lists should be included |
ArchiveConnection Context::getArchiveConnection | ( | String | archiveServerName | ) |
Get an ArchiveConnection object.
With this method you can get an ArchiveConnection object. This object offers several methods to use the EAS Interface, EBIS or the EASY ENTERPRISE XML-Server.
archiveServerName | Optional string containing the archive server name; If the archive server is not defined, then the main archive server will be used |
DocFile Context::getArchiveFile | ( | String | key | ) |
Get a file from the archive.
With this method you can get a file from the archive using the archive key. You need the necessary access rights on the archive side.
DocFile
or NULL
, if failed ArchiveServer Context::getArchiveServer | ( | String | name | ) |
Get an ArchiveServer identified by its name.
name | The technical name of the ArchiveServer. |
null
if failed. ArchiveServerIterator Context::getArchiveServers | ( | ) |
Get an iterator with all ArchiveServers in the DOCUMENTS environment.
String Context::getAutoText | ( | String | autoText | ) |
Get the String value of a DOCUMENTS autotext.
autoText | the rule to be parsed |
String Context::getClientLang | ( | ) |
Get the abbreviation of the current user's portal language.
If you want to return output messages through scripting, taking into account that your users might use different portal languages, this function is useful to gain knowledge about the portal language used by the current user, who is part of the script's runtime context. This function returns the current language as the two letter abbreviation as defined in the principal's settings in the Windows Portal Client (e.g. "de" for German).
int Context::getClientSystemLang | ( | ) |
Get the script's execution context portal language index.
String Context::getClientType | ( | ) |
Get the connection info of the client connection.
You can analyze the connection info to identify e.g. a client thread of the HTML5 Web-Client
String Context::getCurrentUserAttribute | ( | String | attributeName | ) |
Get the String value of an attribute of the current user.
attributeName | the technical name of the desired attribute |
CustomPropertyIterator Context::getCustomProperties | ( | String | nameFilter = "" , |
String | typeFilter = "" |
||
) |
Get a CustomPropertyIterator with global custom properties.
nameFilter | String value defining an optional filter depending on the name |
typeFilter | String value defining an optional filter depending on the type |
number Context::getDatesDiff | ( | Date | earlierDate, |
Date | laterDate, | ||
String | unit = 'days' , |
||
boolean | useWorkCalendar = true |
||
) |
Subtract two Date objects to get their difference.
This function calculates the time difference between two Date objects, for example if you need to know how many days a business trip takes. By default this function takes the work calendar into account if it is configured and enabled for the principal.
earlierDate | Date object representing the earlier date |
laterDate | Date object representing the later date |
unit | optional String value defining the unit, allowed values are "minutes" , "hours" and "days" (default) |
useWorkCalendar | optional boolean to take office hours into account or not (requires enabled and configured work calendar) |
Document Context::getDocumentById | ( | String | idFile, |
String | idDocument | ||
) |
Get the Document by its unique file-id.
If the Document does not exist or the user in whose context the script is executed is not allowed to access the file, then the return value will be null
.
idFile | Unique id of the file |
idDocument | Unique id of the document |
string [] Context::getEnumAutoText | ( | String | autoText | ) |
Get an array with the values of an enumeration autotext.
autoText | to be parsed |
String Context::getEnumErgValue | ( | String | fileType, |
String | field, | ||
String | techEnumValue, | ||
String | locale = "" |
||
) |
Get the ergonomic label of a multilanguage enumeration list value.
Enumeration lists in multilanguage DOCUMENTS installations usually are translated into the different portal languages as well. This results in the effect that only a technical value for an enumeration is stored in the database. So, if you need to display the label which is usually visible instead in the enumeration field through scripting, this function is used to access that ergonomic label.
fileType | String value containing the technical name of the desired filetype |
field | String value containing the technical name of the desired enumeration field |
techEnumValue | String value containing the desired technical value of the enumeration entry |
locale | optional String value with the locale abbreviation (according to the principal's configuration); if omitted, the current user's portal language is used automatically |
String Context::getEnumValues | ( | String | fileType, |
String | field | ||
) |
Get an array with enumeration list entries.
In some cases it might be useful not only to access the selected value of an enumeration file field, but the list of all possible field values as well. This function creates an Array of String values (zero-based), and each index is one available value of the enumeration field. If the enumeration field is configured to sort the values alphabetically, this option is respected.
fileType | String value containing the technical name of the desired filetype |
field | String value containing the technical name of the desired enumeration field |
String Context::getFieldErgName | ( | String | fileType, |
String | field, | ||
String | locale = "" |
||
) |
Get the ergonomic label of a file field.
In multilanguage DOCUMENTS environments, usually the file fields are translated to the different locales by using the well known ergonomic label hack. The function is useful to output scripting generated information in the appropriate portal language of the web user who triggered the script execution.
fileType | String value containing the technical name of the desired filetype |
field | String value containing the technical name of the desired field |
locale | optional String value with the locale abbreviation (according to the principal's configuration); if omitted, the current user's portal language is used automatically |
DocFile Context::getFileById | ( | String | idFile | ) |
Get the file by its unique file-id.
If the file does not exist or the user in whose context the script is executed is not allowed to access the file, then the return value will be null
.
idFile | Unique id of the file |
String Context::getFileTypeErgName | ( | String | fileType, |
String | locale = "" |
||
) |
Get the ergonomic label of a filetype.
In multilanguage DOCUMENTS environments, usually the filetypes are translated to the different locales by using the well known ergonomic label hack. The function is useful to output scripting generated information in the appropriate portal language of the web user who triggered the script execution.
fileType | String value containing the technical name of the desired filetype |
locale | optional String value with the locale abbreviation (according to the principal's configuration); if omitted, the current user's portal language is used automatically |
String Context::getFileTypeOID | ( | String | nameFiletype, |
boolean | oidLow = false |
||
) |
Returns the object-id of a filetype.
nameFiletype | String value containing the technical name of the filetype. |
oidLow | Optional flag: If true only the id of the filetype object (m_oid ) will be returned. If false the id of the filetype object will be returned together with the id of the corresponding class in the form class-id:m_oid . The default value is false . |
String
with the object-id or false
if filetype does not exist int Context::getFolderPosition | ( | Folder | folder | ) |
Retrieve the position of a top level folder in the global context.
This method can be used to get the position of a top level folder (public, public dynamic or only subfolders folder with no parent) in the global context.
folder | Folder object whose position to be retrieved. |
FolderIterator Context::getFoldersByName | ( | String | folderPattern, |
String | type = "" |
||
) |
Retrieve a list of folders with identical name.
Different folders might match an identical pattern, e.g. "DE_20*"
for each folder like "DE_2004"
, "DE_2005"
and so on. If you need to perform some action with the different folders or their contents, it might be useful to retrieve an iterator (a list) of all these folders to loop through that list.
folderPattern | the name pattern of the desired folder(s) |
type | optional parameter, a String value defining the type of folders to look for; allowed values are "public" , "dynamicpublic" and "onlysubfolder" |
String Context::getFromSystemTable | ( | String | identifier | ) |
Retrieve the desired entry of the system messages table.
It might be inconvenient to maintain the different output Strings of localized PortalScripts, if this requires to edit the scripts themselves. This function adds a convenient way to directly access the system messages table which you may maintain in the Windows Portal Client. This enables you to add your own system message table entries in your different portal languages and to directly access them in your scripts.
identifier | String value containing the technical identifer of a certain system message table entry |
object Context::getJSObject | ( | String | oid | ) |
Get a JS_Object by object id.
With this method you can get a JS-Object by the object id. Depending of the class of the object you get a JS-Object of the classes AccessProfile, DocFile, Document, Folder, Register, SystemUser or WorkflowStep
oid | String containing the id of the object |
String Context::getLastError | ( | ) |
Function to get the description of the last error that occurred.
String Context::getLocaleValue | ( | String | value, |
String | locale = "" |
||
) |
Get the value/label of a String with the format "de:rot;en:red;fr:rouge" in the current or defined portal language.
value | String with the complete value string |
locale | Optional String value with the locale abbreviation (according to the principal's configuration); if omitted, the current user's portal language is used automatically. |
String
containing the valuein the appropriate portal language. String Context::getPrincipalAttribute | ( | String | attributeName | ) |
Get the String value of an attribute of the DOCUMENTS principal.
attributeName | the technical name of the desired attribute |
Float Context::getProgressBar | ( | ) |
Gets the current progress value in % of the progress bar in the Documents-Manager during the PortalScript execution.
progress
as float (value >= 0 and value <= 100) DocQueryParams Context::getQueryParams | ( | ) |
Get the actual search parameters within an "OnSearch" or "FillSearchScript" exit.
null
. null
, if the calling script is not running as an "OnSearch" or "FillSearchMask" handler. It can also be null
, if the script has called changeScriptUser(). In order to access the search parameters, the script needs to restore the original user context. String Context::getRegisterErgName | ( | String | fileTypeName, |
String | registerName, | ||
String | locale = "" |
||
) |
Get the ergonomic label of a register.
fileTypeName | String value containing the technical name of the desired filetype |
registerName | String value containing the technical name of the desired register |
locale | optional String value with the locale abbreviation (according to the principal's configuration); if omitted, the current user's portal language is used automatically |
String Context::getServerInstallPath | ( | ) |
Create a String containing the installation path of the portal server.
SystemUser Context::getSystemUser | ( | ) |
Get the current user as a SystemUser object.
SystemUserIterator Context::getSystemUsers | ( | boolean | includeLockedUsers = false | ) |
Get a list of all users created in the system.
includeLockedUsers | optional definition, if locked users also should be returned |
String Context::getTempPathByToken | ( | String | accessToken, |
boolean | dropToken = true |
||
) |
Returns the temporary server path, that was ordered by the gadget API for the token.
accessToken | String value with the token |
dropToken | Optional Boolean value that indicates the server to forget the token |
String Context::getTmpFilePath | ( | ) |
Create a String containing a complete path and filename to a temporary file.
The created file path may be used without any danger of corrupting any important data by accident, because DOCUMENTS assures that there is no such file with the created filename yet.
ArchiveConnection Context::getXMLServer | ( | String | archiveServerName = "" | ) |
Get an ArchiveConnection object.
With this method you can get an ArchiveConnection object. This object offers several methods to use the EAS Interface, EBIS or the EASY ENTERPRISE XML-Server.
archiveServerName | Optional string containing the archive server name; If the archive server is not defined, then the main archive server will be used |
Boolean Context::hasPEMModule | ( | Integer | moduleConst | ) |
Function to check if a module is licenced in the pem.
moduleConst | from PEM Module Constants. |
true
if licenced, otherwise false
boolean Context::reloadCurrentPrincipal | ( | boolean | pemReload = false | ) |
Reloads the current principal.
This function invalidates or clears caches (e.g. PortalScriptCache
and ScriptEnumCache
) in order to reload them. Where appropriate you can also with this method reload the pem-file for the current principal via the parameter pemReload
.
pemReload | Optional boolean indicating whether the pem-file for the current principal to be reloaded. The default value is false . |
true
if successful, false
in case of any error. boolean Context::reloadPrincipal | ( | String | principalName, |
boolean | pemReload = false |
||
) |
Reloads the desired principal.
This function invalidates or clears caches (e.g. PortalScriptCache
and ScriptEnumCache
) in order to reload them. Where appropriate you can also with this method reload the pem-file for the desired principal via the parameter pemReload
.
principalName | String containing the name of the principal to be reloaded. |
pemReload | Optional boolean indicating whether the pem-file for the desired principal to be reloaded. The default value is false . |
true
if successful, false
in case of any error. String Context::sendTCPStringRequest | ( | String | server, |
int | port, | ||
String | request, | ||
int | responseTimeout = 3000 |
||
) |
Send a String as TCP-Request to a server.
With this method it is possible to send a String via TCP to a server. The return value of the function is the response of the server. Optional you can define a timeout in ms this function waits for the response of a server
server | String containing the IP address or server host |
port | int containing the port on which the server is listening |
request | String with the request that should be sent to the server |
responseTimeout | int with the timeout for the response in ms. Default value is 3000ms |
String Context::setClientLang | ( | String | locale | ) |
Set the abbreviation of the current user's portal language.
If you want to set the portal language different from the current users language, you can use this method. As parameter you have to use the two letter abbreviation as defined in the principal's settings in the Windows DOCUMENTS Manager (e.g. "de" for German).
locale | String containing the two letter abbreviation for the locale |
true
if successful, false
in case of any error boolean Context::setClientSystemLang | ( | int | langIndex | ) |
Set the script's execution context portal language to the desired language.
langIndex | integer value of the index of the desired system language |
true
if successful, false
in case of any error boolean Context::setFolderPosition | ( | Folder | folder, |
int | position | ||
) |
Place a top level folder a at given position in the global context.
This method can be used to set the position of a top level folder (public, public dynamic or only subfolders folder with no parent) in the global context.
folder | Folder object whose position to be set. |
position | new internal position number of folder. |
true
if successful, false
in case of any error. CustomProperty Context::setOrAddCustomProperty | ( | String | name, |
String | type, | ||
String | value | ||
) |
Creates or modifies a global custom property according the name and type.
name | String value defining the name |
type | String value defining the type |
value | String value defining the value |
boolean Context::setPrincipalAttribute | ( | String | attributeName, |
String | value | ||
) |
Set an attribute of the DOCUMENTS principal to the desired value.
attributeName | the technical name of the desired attribute |
value | the value that should be assigned |
true
if successful, false
in case of any error void Context::setProgressBar | ( | float | value | ) |
Sets the progress (%) of the progress bar in the Documents-Manager during the PortalScript execution.
value | Float with in % of the execution (value >= 0 and value <= 100) |
void Context::setProgressBarText | ( | String | text | ) |
Sets the progress bar text in the Documents-Manager during the PortalScript execution.
text | String with the text to displayed in the progress bar |
boolean Context::writeLogBook | ( | int | actionCode, |
String | detail1, | ||
String | detail2, | ||
String | detail3 | ||
) |
Logs an executed action to the logbook.
actionCode | The integer code of the executed action to be logged. Range: 0 to 35 described as follows:
|
detail1 | Optional String with length <= 255 containing additional information of the action. if the string length > 255, only the first 255 characters will be displayed. |
detail2 | Optional String with length <= 60 containing additional information of the action. if the string length > 60, only the first 60 characters will be displayed. |
detail3 | Optional String with length <= 60 containing additional information of the action. if the string length > 60, only the first 60 characters will be displayed. |
true
if successful, false
in case of any error. String Context::clientId |
Id of the client / thread which is the execution context of the script.
This property is helpful to identify the clients at scripts running concurrently (for debugging purposes).
String Context::currentUser |
Login of the user who has triggered the script execution.
If the script is running e.g. as action in the workflow the user is the logged in user, who has initiated the action.
Document Context::document |
String Context::errorMessage |
Error message text to be returned by the script.
The error message will be displayed as Javascript alert box in the web client if the script is called in context of a web client.
String Context::event |
Event which triggered the script execution.
According to the context where the portal script has been called this property contains a key name for this event.
The following events are available:
"afterMail"
"afterSave"
"attributeSetter"
"autoText"
"condition"
"custom"
"fileAction"
"folderAction"
"moveTrash"
"newFile"
"onAutoLogin"
"onArchive"
"onDelete"
"onDeleteAll"
"onEdit"
"onLogin"
"onSave"
"test"
"workflow"
String Context::fieldName |
Returns in an enumeration script the name of the field where the script is executed for.
If the script is an enumeration script, this member contains the field name of the current field where the script is executed. This is particularly helpful when the script is set at more than one enumeration field and the behaviour of the script should depend on the field.
DocFile Context::file |
String Context::fileType |
Technical name of the filetype of the file which is the execution context of the script.
This property contains the technical name of the filetype of the file which is the execution context of the script.
Folder Context::folder |
FileResultset Context::folderFiles |
FileResultset with all files of a folder.
This property allows to retrieve a list of all files of a folder if this script is run as user defined action at the folder. You can then iterate through this list for further use of the distinct files.
String Context::folderName |
Technical name of the folder the script is called from.
This property contains the technical name of the folder which is the execution context of the script.
String Context::qsession |
Session id of the current query-session.
Register Context::register |
String Context::returnType |
Type of the return value that the script returns.
User defined actions attached to a file or a folder allow to influence the behaviour of the Web-Client. As soon as you define a return type you explicitely have to return a value.
The following types of return values are available:
"html"
- The return value contains html-content. "stay"
- The continues to display the current file (this is the default behaviour). "showFile"
- The return value contains the file-id and optional the register-id of a file to be displayed after the script has been executed. Syntax: file-id[&dlcRegisterId=register-id]
. "showFolder"
- The return value contains the folder-id of a folder to be displayed. "updateTree"
- The return value contains the folder-id of a folder to be displayed. The folder tree will be updated as well. "showNewFile"
- The return value contains the file-id of a file to be displayed. This file will automatically open in edit mode and will be deleted at cancellation by the user. "showEditFile"
- The return value contains the file-id of a file to be displayed. This file will automatically open in edit mode. "file:filename"
- The web user will be asked to download the content of the return value (usually a String variable) to his client computer; The filename filename
will be proposed as a default. "download:filename"
- The web user will be asked to download the blob, that is specified in the return value (server-sided path to the blob), to his client computer; The filename filename
will be proposed as a default.showNewFile, updateTree, file
) showFile
with return value of file-id and register-idString Context::scriptName |
Name of the executed script.
ArchiveFileResultset Context::selectedArchiveFiles |
Iterator with the selected archive files of a folder.
This property allows to retrieve a list of the selected archive files of a folder if this script is run as user defined action at the folder. You can then iterate through this list for further use of the distinct files.
string [] Context::selectedArchiveKeys |
Array with the keys of the selected archive files of a folder.
This property allows to retrieve an array with the keys of the selected archive files of a folder if this script is run as user defined action at the folder.
DocumentIterator Context::selectedDocuments |
DocumentIterator with the selected Documents (attachments) of the current document register.
This property allows to retrieve a list of all selected Documents of a register if this script is run as user defined action at the register.
FileResultset Context::selectedFiles |
Iterator with the selected files of a folder.
This property allows to retrieve a list of the selected files of a folder if this script is run as user defined action at the folder. You can then iterate through this list for further use of the distinct files.
String Context::sourceCode |
Script source code of the script after including other scripts by the #import rule.
This property is useful for debugging purposes, if you need to have a look for a certain line of code to find an error, but the script contains other imported sub scripts which mangle the line numbering.
String Context::workflowActionId |
Id of the locking WorkflowStep for the user for the current file.
String Context::workflowActionName |
Name of the locking WorkflowStep for the user for the current file.
String Context::workflowControlFlowId |
Id of the ControlFlow the current file currently passes.
String Context::workflowControlFlowName |
Name of the ControlFlow the current file currently passes.
WorkflowStep Context::workflowStep |
Returns the current workflowstep if the script is run in context of a workflow.
E.g. as guard or decision script.