Constructors
The universal interface for user-exits, gentable and gadgets. It includes opening of dialogs and navigation
to folders, files, the extended search other etc. Additional interfaces are available via the
UserContext,
FileContext,
GadgetContext and the
GentableContext.
- Since:
- 5.0a
Methods
-
closeDialog()
-
Closes any dialog that is currently displayed.
- Since:
- 5.0a
Example
documentsContext.closeDialog(); -
closeGadget()
-
Closes a gadget. Currently only useful when the gadget is used in a popup dialog.
- Since:
- 5.0
-
encodeURL(url){String}
-
Encodes an URL by adding the
jsessionidand thecnvidto it. Ajsessionidis provided if cookies are disabled only.
URLs must be encoded always if calling custom servlets or jsps and access to the tomcat server session is required.Name Type Description urlString the url to be encoded
- Since:
- 5.0a
Returns:
Type Description String the encoded url Examples
var encodedUrl = documentsContext.encodeURL("./ext/jsp/invoice/table.jsp"); // "./ext/jsp/invoice/table.jsp;cnvid=NeRbCno7Vbp5Wj07" (cookies enabled) // "./ext/jsp/invoice/table.jsp;jsessionid=686826E7F0B8212A3D97010F3ECB1936;cnvid=NeRbCno7Vbp5Wj07" (cookies disabled)var encodedUrl = documentsContext.encodeURL("./ext/jsp/invoice/table.jsp" + "?" + documentsContext.getBaseParamsQueryString()); // "./ext/jsp/invoice/table.jsp;cnvid=NeRbCno7Vbp5Wj07?pri=dopaag&lang=de" (cookies enabled) // "./ext/jsp/invoice/table.jsp;jsessionid=686826E7F0B8212A3D97010F3ECB1936;cnvid=NeRbCno7Vbp5Wj07?pri=dopaag&lang=de" (cookies disabled) -
executeScript(scriptName, scriptParams, options){Promise|String|undefined}
-
Executes a server-side global script by its name. Any defined script parameters can be transmitted alike.
The script can either be called synchronous (default) or asynchronous (via options parameter).
If the script result has a definedreturnType(defined by context.returnType in the portal script) the
function has no return value and the output depends on the returnType.
With the optiondispatchit is possible to always retrieve the script result even if a returnType is defined.
options.dispatch must be set to false (defaults to true) to use the script result as return value.
Withoption.async = truethe function always returns a Promise object. If this option is set it is also
possible to input script parameters defined in the Documents Manager via a dialog. Script parameters added via dialog
will override duplicatescriptParamskeys.Name Type Description scriptNameString the name of the script
scriptParamsObject optional the input parameters for the script
optionsObject optional additional options
Name Type Description dispatchString optional default true, if false scriptResult is returned even if the script has a returnType
asyncString optional default false, if true the script will be executed asynchronous and will return a promise
useScriptParameterDialogString optional default false, if true a script parameter dialog will always be displayed if the script has defined parameter, only works if options.async = true
dialogTitleString optional the title of the script parameter dialog
- Since:
- 5.0a
Returns:
Type Description Promise | String | undefined Promise if options.async === true (see example below), undefined if script result contains returnType, script result String otherwise Examples
var scriptResult = documentsContext.executeScript("countryScript", { country : "Austria" }, { async : false }); // scriptResult: "Burgenland, Kärnten, Niederösterreich, Oberösterreich, Salzburg, Steiermark, Tirol, Vorarlberg, Wien"var promise = documentsContext.executeScript("countryScript", { country : "Austria" }, { async : true }); promise.then(function(value) { console.log(value); // "Burgenland, Kärnten, Niederösterreich, Oberösterreich, Salzburg, Steiermark, Tirol, Vorarlberg, Wien" });var scriptResult = documentsContext.executeScript("aScriptWithReturnType", {param: 'value1'}, { dispatch : false }); // scriptResult is given even if the script has a returnType because dispatch is set to false---example script--- var capitals = { "Germany" : "Berlin", "Austria" : "Vienna", ... }; return JSON.stringify(capitals); ---example script--- // if options.async === false, the server always returns a string no matter what the original format in the script was. Example to transfer and receive a JSON Object: var jsonString = documentsContext.executeScript("exampleScript", { }, { async : false }); var capitals = JSON.parse(jsonString); // capitals: { "Germany" : "Berlin", "Austria" : "Vienna", ... } -
getBaseParams(){Object}
-
Returns all documents application related base parameters as object. It includes both the principal (
pri) and the language (lang) parameter.- Since:
- 5.0a
Returns:
Type Description Object the base parameters Example
var urlBaseParams = documentsContext.getBaseParams(); // -> { "pri" : "dopaag", "lang" : "en" } -
getBaseParamsQueryString(){String}
-
Returns the query string of all documents application related base parameters as query string. It includes both the principal (
pri) and the language (lang) parameter.- Since:
- 5.0a
- See:
Returns:
Type Description String the query string of the base parameters Example
var urlBaseParams = documentsContext.getBaseParamsQueryString(); // -> "pri=dopaag&lang=en" -
getExtendedSearchContext(){ExtendedSearchContext}
-
Returns an
ExtendedSearchContext.- Since:
- 5.0b
Returns:
Type Description ExtendedSearchContext The ExtendedSearchContext Example
var extSearchContext = documentsContext.getExtendedSearchContext(); -
getFileContext(){FileContext}
-
Returns a
FileContext.- Since:
- 5.0a
Returns:
Type Description FileContext The FileContext Example
var fileContext = documentsContext.getFileContext(); -
getGadgetContext(){GadgetContext}
-
Returns a
GadgetContext.- Since:
- 5.0c
Returns:
Type Description GadgetContext The GadgetContext Example
var gadgetContext = documentsContext.getGadgetContext(); -
getGentableContext(){GentableContext}
-
Returns a
GentableContext.- Since:
- 5.0a
Returns:
Type Description GentableContext The GentableContext Example
var gentableContext = documentsContext.getGentableContext(); -
getI18nContext(){I18nContext}
-
Returns an
I18nContext.- Since:
- 5.0b
Returns:
Type Description I18nContext The I18nContext -
getLocalStorage(key){LocalStorage}
-
Returns a persistent local web storage by its key. If the key is omitted, a "custom" local storage is returned by default.
Name Type Description keyString the key of the storage
- Since:
- 5.0c
Returns:
Type Description LocalStorage The LocalStorage Examples
var localStorage1 = documentsContext.getLocalStorage("oceanic");var localStorage2 = documentsContext.getLocalStorage(); // "custom" -
getSessionStorage(key){SessionStorage}
-
Returns a transient session web storage by its key. If the key is omitted, a "custom" session storage is returned by default.
Name Type Description keyString the key of the storage
- Since:
- 5.0c
Returns:
Type Description SessionStorage The SessionStorage Examples
var sessionStorage1 = documentsContext.getSessionStorage("oceanic");var sessionStorage2 = documentsContext.getSessionStorage(); // "custom" -
getURL(type, options){String}
-
Creates and returns a documents application servlet url by a defined type. Optional parameters must be provided in some cases.
Name Type Description typeString the type of the servlet url that should be returned
annotation(options:fileId,documentId) URL to access the annotations of a pdf/tif file
controlSheet(options:fileId,registerId) URL for a control sheet
gadgetURL for a gadget
docDownloadURL to download a file (options:fileId,documentId,attachmentType,versionId,attachmentMode)
pdfjsViewerURL to access the pdfjs viewer
otrisViewerURL to access the otris viewer
reportURL for a report
docUploadURL to access the upload servlet
userLoginURL to login the current user
userLogoutURL to logout the current useroptionsObject optional additional options needed for some types
Name Type Description absoluteString optional default false, if true the function will return an absolute url, otherwise a relative url
fileIdString optional the id of the file
documentIdString optional the id of the file document
registerIdString optional the id of the file register
filenameString optional the file name of a file document
attachmentModeBoolean optional attachmentTypeString optional versionIdString optional the id of a file document version
- Since:
- 5.0c
Returns:
Type Description String the created url Example
var fileContext = documentsContext.getFileContext(); var urlParams = { fileId : fileContext.getFileId(), documentId : fileContext.getDocumentId() }; documentsContext.getURL("annotation", urlParams); // -> "http://localhost:8081/srv/annotation;cnvid=[...];jsessionid=[...]?fileId=dopaag_fi201600000386&documentId=dopaagdc00000000000289" -
getUserContext(){UserContext}
-
Returns the
UserContextof the current system user.- Since:
- 5.0a
Returns:
Type Description UserContext The UserContext Example
var userContext = documentsContext.getUserContext(); -
openConfirmationDialog(title, message, onOk, onCancel, onClose)
-
Displays a dialog window that requests the current system user for confirmation.
The dialog window is displayed in front of the main window and system users always have to interact with it before they can return to the main window.
Note that unlike awindow.prompt()dialog, the execution of the current program flow is not paused until the user cancels or confirms the dialog.Name Type Description titleString the title of the dialog window
messageString the confirmation message text
onOkfunction a function that is executed if the user clicks "OK"
onCancelfunction a function that is executed if the user clicks "Cancel"
onClosefunction a function that is executed if the user clicks "OK", "Cancel" or "X". The function is executed after the onOk or onCancel function.
- Since:
- 5.0a
- See:
Example
var title = "Confirmation Dialog"; var message = "Confirmation message text inside the dialog."; var onOk = function() { console.log("onOk"); } var onCancel = function() { console.log("onCancel"); } var onClose = function() { console.log("onClose"); } documentsContext.openConfirmationDialog(title, message, onOk, onCancel, onClose); -
openExtendedSearchView()
-
Changes the current view to the extended search view.
Caution: This function will not process any actions if the user is currently in edit mode.- Since:
- 5.0a
-
openFileView(fileId, registerId, documentId, options)
-
Changes the current view to a file view. It is allowed to navigate to a file (cover), to a register or to a document.
Caution: This function will not process any actions if the user is currently in edit mode.Name Type Description fileIdString the id of the file
registerIdString optional the id of the file register
documentIdString optional the id of the file document
optionsObject optional Name Type Description autoOpenDocumentModeBoolean optional , default: true
checkConstraintsBoolean optional if constraints should be checked or not, default: true
startFileEditModeBoolean optional if file edit mode should be started or not, default: false
registerBarStateString optional "open", "min", "closed", default :
- Since:
- 5.0a
Examples
documentsContext.openFileView(fileId);documentsContext.openFileView(fileId, registerId);documentsContext.openFileView(fileId, registerId, documentId);documentsContext.openFileView(fileId, null, null, { startFileEditMode : true, registerBarState : "closed" }); -
openFolderView(folderId)
-
Changes the current view to a folder view. It is allowed to navigate to any private or public folder.
Caution: This function will not process any actions if the user is currently in edit mode.Name Type Description folderIdString the id of the folder
- Since:
- 5.0a
-
openFrameDialog(title, frameSrc, options)
-
Displays a dialog with an embedded iframe.
Name Type Description titleString the title of the dialog window
frameSrcString the url of the embedded iframe
optionsObject Name Type Description widthNumber optional the width of the dialog, default: 400
heightNumber optional the height of the dialog, default: 300
topNumber optional the distance from the top of the window
leftNumber optional the distance from the left of the window
frameStylesObject optional the styles of the dialog
frameStyleClassesObject optional the classes of the dialog
onClosefunction optional function to execute when close is clicked
onOkfunction optional function to execute when ok is clicked
onCancelfunction optional function to execute when cancel is clicked
- Since:
- 5.0c
Example
var title = "Product"; var url = documentsContext.encodeURL("./ext/jsp/invoice/table.jsp" + "?" + documentsContext.getBaseParamsQueryString()); documentsContext.openFrameDialog(title, url, { width : 800, height : 400, frameStyles : { background-color : "darkgrey" }, frameStyleClasses : [ "dialogFrame" ], onClose : function() { console.log("onClose"); }, onOk : function() { console.log("onOk"); }, onCancel : function() { console.log("onCancel"); } }); -
openHomeView()
-
Changes the current view to the start screen view.
Caution: This function will not process any actions if the user is currently in edit mode.- Since:
- 5.0d
Example
documents.sdk.exitRegistry.registerFileFieldExitCallback("erpInvoice", "erpInvoiceNumber", function(documentsContext, options) { documentsContext.openHomeView(); } -
openHtmlDialog(title, html, onOk, onClose)
-
Displays a html dialog window.
The dialog window is displayed in front of the main window and system users always have to interact with it before they can return to the main window.
Note that unlike awindow.alert()dialog, the execution of the current program flow is not paused until the user cancels or confirms the dialog.Name Type Description titleString the title of the dialog window
htmlString the inner html content source
onOkfunction a function that is executed if the user clicks "OK"
onClosefunction a function that is executed if the user clicks "OK" or "X". The function is executed after the onOk function.
- Since:
- 5.0a
- See:
Example
var title = "HTML Dialog"; var html = "<div style=\"background-color: darkgrey; color: darkred;\">TestDiv</div>"; var onOk = function() { console.log("onOk"); } var onClose = function() { console.log("onClose"); } documentsContext.openHtmlDialog(title, html, onOk, onClose); -
openMessageDialog(title, message, onOk, onClose)
-
Displays a message dialog window.
The dialog window is displayed in front of the main window and system users always have to interact with it before they can return to the main window.
Note that unlike awindow.alert()dialog, the execution of the current program flow is not paused until the user cancels or confirms the dialog.Name Type Description titleString the title of the dialog window
messageString the message text
onOkfunction a function that is executed if the user clicks "OK"
onClosefunction a function that is executed if the user clicks "OK" or "X". The function is executed after the onOk function.
- Since:
- 5.0a
- See:
Example
var title = "Message Dialog"; var message = "Message text inside the dialog."; var onOk = function() { console.log("onOk"); } var onClose = function() { console.log("onClose"); } documentsContext.openMessageDialog(title, message, onOk, onClose); -
openOutbar(options)
-
Opens the outbar with the given name.
Name Type Description optionsObject Name Type Description nameString Possible values:
OutbarPublicFolder //The outbar for public folders (Documents Manager - Settings - Documents (display) - Combined folder tree not checked)
OutbarPrivateFolder //The outbar for private folders (Documents Manager - Settings - Documents (display) - Combined folder tree not checked)
OutbarCombinedFolder //The outbar for a combination of public and private folders (Documents Manager - Settings - Documents (display) - Combined folder tree checked)
OutbarHitTree //The outbar for a hit tree (Documents Manager - Settings - Global Settings - Hit tree checked)
User defined outbars can be accessed by their name (Documents Manager - settings - Outbars).- Since:
- 5.0d
Example
documents.sdk.exitRegistry.registerFileFieldExitCallback("erpInvoice", "erpInvoiceNumber", function(documentsContext, options) { documentsContext.openOutbar({ name: "OutbarPublicFolder" }); } -
openTableDataDialog(title, url, options)
-
Opens a dedicated dialog for the tabledata plugin.
Basically, there are two different dialog types available, one (internal) iframe dialog (default) and another (external) popup window dialog.
The internal iframe dialog appears like an ordinary DOCUMENTS 5 dialog, the external popup window dialog is the more traditional way.
This function supports fully automatic setting of file field data, gentable row data or email dialog recipient data on a tabledata row selection.
Alternatively, a custom handler function can be implemented which will be executed on tabledata row selection.
If the automatic field setting should be used, theexitOptionsoption must be specified. Otherwise, if a custom row selection handler should be used, the theonSelectoption must be specified.
If both options are set by accident,onSelectoption overrides theexitOptionsoption and also any automatic data setting.
See the examples below for recommended implementations ofdetail.jsp. Legacy D5 implementations ofdetail.jspare fully supported so updating the code is not mandatory in most cases.Name Type Description titleString the title of the dialog window
urlString the url of the
table.jspoptionsObject Name Type Description onSelectfunction optional custom handler function that is executed after the selection of a tabledata row entry, the selected data is available as a function parameter.
Notice: If this option is set, none of the fields will be set automatically.exitOptionsObject optional the
optionsobject of the registered exit callback function, see examples below for details.
Should be provided ifoptions.onSelectoption is not set.popupWinBoolean optional true, if an (external) popup window should be used to display the tabledata, otherwise an (internal) iframe dialog is used (default)widthNumber optional the width of the dialog, default: 400
heightNumber optional the height of the dialog, default: 300
topNumber optional the top position of the dialog
leftNumber optional the left position of the dialog
onClosefunction optional custom handler function that is executed when the dialog is closed, not available if
popupWin: trueis setsortColumnString optional the column that sorts the tabledata, add '+' or '-' at the end of the column name to set the sort order. Default: '+'
searchTextString optional the default search text, tabledata is searched on opening
searchColumnString optional the column to search the searchText in
paramsObject optional additional parameter that will be added to the url
- Since:
- 5.0c
Examples
**custom tabledata row selection handler** documents.sdk.exitRegistry.registerFileFieldExitCallback("crmContact", "crmName", function(documentsContext, options) { var title = "Ansprechpartner"; var url = documentsContext.encodeURL("./ext/jsp/tabledata/table.jsp" + "?" + documentsContext.getBaseParamsQueryString()); documentsContext.openTableDataDialog(title, url, { width: 1000, height: 400, popupWin: false, // optional onSelect: function(data) { documentsContext.openMessageDialog("", JSON.stringify(data)); console.log(data); }, sortColumn: "PLZ-", //sort with column PLZ in descending order searchColumn: "PLZ", //search in column PLZ searchText: "531" //search for values that contain 531 }); });**automatic field data setting** documents.sdk.exitRegistry.registerFileExitCallback("crmContact", "FileEmail.recipients", function(documentsContext, options) { var title = "Ansprechpartner"; var url = documentsContext.encodeURL("./ext/jsp/email/table.jsp" + "?" + documentsContext.getBaseParamsQueryString()); documentsContext.openTableDataDialog(title, url, { width: 1000, height: 400, popupWin: false, // optional exitOptions: options // mandatory for automatic field setting }); });**detail.jsp, file field data** var fieldData = { crmName: '<tab:detail id="Firmentabelle" name="Kontaktperson" escapeMode="script" removeCRLF="true" />'.split(/\s+/)[1], // split "firstName lastName" crmFirstName: '<tab:detail id="Firmentabelle" name="Kontaktperson" escapeMode="script" removeCRLF="true" />'.split(/\s+/)[0], // split "firstName lastName" crmAccountnumber: '<tab:detail id="Firmentabelle" name="Kunden-Code" escapeMode="script" removeCRLF="true" />', [...] }; (window.opener || parent).postMessage({ action: "<%= request.getParameter("actionId") %>", data: fieldData }, "*");**detail.jsp, gentable row data** var rowData = { amount: '<tab:detail id="Firmentabelle" name="Lagerbestand" escapeMode="script" removeCRLF="true" />', itemno: '<tab:detail id="Firmentabelle" name="Artikel-Nr" escapeMode="script" removeCRLF="true" />', [...] }; (window.opener || parent).postMessage({ action: "<%= request.getParameter("actionId") %>", data: rowData }, "*");**detail.jsp, email dialog recipient data** var emailData = { lastName: '<tab:detail id="Personaltabelle" name="Nachname" escapeMode="script" removeCRLF="true" />', firstName: '<tab:detail id="Personaltabelle" name="Vorname" escapeMode="script" removeCRLF="true" />' }; (window.opener || parent).postMessage({ action: "<%= request.getParameter("actionId") %>", data: emailData.firstName + "." + emailData.lastName + "@dopa.ag" }, "*"); -
startBusyPanel(view)
-
This function locks a defined view for the current user by a view identifier.
Valid view identifiers areWorkspace,MainTree,MainList,MainFile,MainFileGentable.Name Type Description viewString the identifier of the view that is to be locked
- Since:
- 5.0b
- See:
Example
// notice: example uses an asynchronous script action call (with promise) var fileContext = documentsContext.getFileContext(); documentsContext.startBusyPanel("MainFile"); fileContext.executeScript("countryScript", { country : "Austria" }, { "async" : true }).then( function(result) { // process the file script action result documentsContext.stopBusyPanel("MainFile"); }); -
stopBusyPanel(view)
-
This function unlocks a defined view for the current user by a view identifier.
Valid view identifiers areWorkspace,MainTree,MainList,MainFile,MainFileGentable.Name Type Description viewString the identifier of the view that is to be unlocked
- Since:
- 5.0b
- See:
-
updateFileView()
-
Updates the current file view.
In file edit mode, this operation automatically stores the values of all visible file fields while ignoring any constraints.- Since:
- 4.0