DOCUMENTS 5 - PortalScripting API
Script Exits


Overview

Creating, Editing, Deleting Files

Workflow

E-Mail

Check-In / Check-Out

Archive

User

Access Rights

Document Retrieval

Global Scripts



Creation, Editing, Deletion of a File

on creating a file

Where to define On register Scripting at filetype: On creating new files
Context.event newFile
return value no
Available properties Context.currentUser, Context.file
This script exit will be called after creation of a new file with the default values and before the file is send into the workflow (if a workflow is defined at the filetype). The exit will also be called on direct creation of a DOCUMENTS (EAS) archive file.

before editing a file

Where to define Property at filetype: beforeEditScript=ScriptName
Context.event beforeEdit
return value return value != 0 will be evaluated as error and the EDIT-action will be canceled.
Available properties Context.currentUser, Context.file, Context.workflowActionId, Context.workflowActionName

This script will be called if a user presses the EDIT button on a file. At start time of the script execution, the file is in its original state. A scratch copy does not yet exist. If the script returns a value != 0, the EDIT action will be canceled and the value of Context.errorMessage will be display in an alert window.

You can use this exit e.g. to deny the edit-access in dependency of the logged in user. In connection with EAS/EDA, the exit will also be called for an EDIT action on an archived file, but not for a REACTIVATE action.

on editing a file

Where to define On register Scripting at filetype: On editing
Context.event onEdit
return value no
Available properties Context.currentUser, Context.file, Context.workflowActionId, Context.workflowActionName

This script exit will be called if an user press the EDIT button at a file. At starting time of the script's execution, the file is in edit mode. The script works with a scratch copy.

In connection with EAS/EDA, the exit will also be called for an EDIT or a REACTIVATE action on an archived file.

after setting reference field

Where to define Property at filetype field of data type reference or filetype: afterSetReferenceFieldScript=Scriptname
Since 4.0d
Context.event afterReferenceFieldSelect / afterReferenceFieldDeselect
return value No
Available properties Context.currentUser, Context.file, referenceFieldName

This script exit allows to run a PortalScript after a field of the datatype "Reference" is set or unset. The property can be defined at the filetype field or global at the filetype. A global definition at the file type will be used for all reference fields of this file type.

util.out("context.event:" + context.event);
util.out("referencefieldName: " + referenceFieldName);
var docFile = context.file;
util.out(docFile.getAutoText("id"));
if (docFile.getScratchCopy())
{
util.out("context.file is an original");
}
else if (docFile.getOriginal())
{
util.out("context.file is a scratch copy");
}
if (context.event == "afterReferenceFieldSelect")
{
var refFile = docFile.getReferenceFile(referenceFieldName);
util.out("Reference-file: " + refFile.getAutoText("title"));
}
else if (context.event == "afterReferenceFieldDeselect")
{
var refFile = docFile.getReferenceFile(referenceFieldName);
if (refFile != null)
{
util.out("Error! RefFile must be null!");
}
}

on saving a file

Where to define On register Scripting at filetype: On saving
Context.event onSave
return value return value != 0 will be evaluated as error and the SAVE-action will be canceled.
Available properties Context.currentUser, Context.file, Context.workflowActionId, Context.workflowActionName

This script exit will be called if an user press the SAVE button at a file. At starting time of the script's execution, the file is still a scratch copy. If you return a value != 0 the value of Context.errorMessage will be display in an alert window. The file will still be in edit mode.

You can use this exit e.g. to validate the input, that the user has entered for the fields. The exit is not available for archived files.

after saving a file

Where to define On register Scripting at filetype: After saving
Context.event afterSave
Available Context.returnType showFile
return value 0 or returnType
Available properties Context.currentUser, Context.file, Context.workflowActionId, Context.workflowActionName
This script exit will be called after an user press the SAVE button at a file. At starting time of the script's execution, the file is again an active file, not a scratch copy. The exit is not available for archived files.

after cancelling editing

Where to define Property at filetype: afterCancelEditScript=ScriptName
Context.event afterCancelEdit
return value value != 0 for an alert window
Available properties Context.currentUser, Context.file, Context.workflowActionId, Context.workflowActionName
This script exit will be called if an user press the CANCEL button in the edit mode of a file. At starting time of the script's execution, the file is not in edit mode anymore. If the script returns a value != 0, the value of Context.errorMessage will be display in an alert window.

on uploading document

Where to define Property at filetype, register, documents-settings: onUploadDocumentScript=Scriptname
Context.event onUploadDocument / onUploadNewDocument
return value return value != 0 will abort the upload
Available properties Context.currentUser, Context.file, Context.register, param.fileName, param.filePath

This script exit will be called if an user uploads a new document or overwrites an existing document. At starting time of the script's execution, the document is uploaded to the server-side, but not yet in the document-repository. Therefore you can cancel the upload with this exit. The parameter param.filePath and param.fileName contains the path to the server-sided temporary directory where the uploaded document is located. The parameter param.fileName contains the name incl. extension of document. You have read/write access to these both parameter. Therefore you can e.g. modify the document name or check the size of the document if you want to realize a size-limit.

// Sample: size limit for new documents of 1MB
if (context.event == "onUploadNewDocument")
{
if (util.fileSize(param.filePath) > 1024*1024)
{
util.out("Size limit exceeded for document: " + param.fileName);
return -1;
}
}

after uploading document

Where to define Property at filetype, register, documents-dettings: afterUploadDocumentScript=Scriptname
Context.event afterUploadNewDocument / afterUploadDocument
return value No
Available properties Context.currentUser, Context.file, Context.register, param.fileName, param.filePath
This script exit will be called after an user uploaded a document.

on deleting a file

Where to define

On register Scripting at filetype: On deleting
Context.event onDelete / moveTrash / onDeleteAll
return value return value != 0 will abort the delete action
Available properties Context.currentUser, Context.file

This script exit will be called if an user deletes a file. At starting time of the script's execution, the file is still existing. If the script returns a value != 0, the delete action will be canceled and the value of Context.errorMessage will be display in an alert window.

It is also possible to use this exit with a DOCUMENTS (EAS) store, but not trivial. In such an environment, please pay attention to the following technical notes.

  • Prior to DOCUMENTS 4.0c the exit was not called for archived files, when the user triggered a delete action in a list view.
  • Since DOCUMENTS 4.0c, the exit is by default also called for archived files in a list-oriented delete operation.
  • The additional calls of the exit can be deactivated again by setting the property EASTriggerOnDeleteFromList to 0 or false. Single delete operations (from a file view) and active files are not affected. The property can be applied to a single EAS store. Using the DOCUMENTS/settings window, it can be applied at once to all the stores, which have not got an individual setting.
  • Before DOCUMENTS can call the exit for an archived file, it must have created a corresponding temporary file in its database. Otherwise it only requires the (already known) external id. Thus the onDelete exit may significantly slow down the process of deleting multiple archive files at once.
  • Starting with DOCUMENTS 4.0d, users may get an option to delete all archived versions of a file at once. In this use case the exit is called for each selected file, but not for each version of each selected file. Context.event indicates this case with the value "onDeleteAll".

on undeleting a file

Where to define Property at Filetype: onUndeleteScript=ScriptName
Context.event onDelete
return value return value != 0 will abort the undelete action
Available properties Context.currentUser, Context.file
This script exit will be called if an user moves a file from the trash folder into the in-work folder. At starting time of the script's execution, the file is still in the trash-folder. If the script returns a value != 0, the undelete action will be canceled and the value of Context.errorMessage will be display in an alert window.

after docimport

Where to define Property at filetype: afterDocimportScript=ScriptName
Context.event afterDocimport
return value no
Available properties Context.currentUser, Context.file, Context.workflowActionId, Context.workflowActionName
This script exit will be called after importing a file by use of docimport.



Workflow

on forwarding a file

Where to define Property at Filetype: onForwardFileScript=Scriptname
Context.event workflow
return value return value != 0 will abort the action
Available properties Context.currentUser, Context.file, Context.workflowActionId, Context.workflowActionName
This script exit will be called if a user presses a forward action in a workflow (only workflow engine, not distribution lists). At starting time of the script's execution, the file is still not forwarded. If the script returns a value != 0, the workflow action will be canceled and the value of Context.errorMessage will be displayed in an alert window.

on connecting file to inbox

Where to define Property at Filetype, SystemUser or Documents-Settings: onConnectInboxScript=Scriptname
Context.event onConnectInbox
return value No
Available properties Context.currentUser, Context.file, Context.folder, Context.workflowStep
This script exit will be called if a file is connected to a users inbox (workflow, follow-up etc). Context.folder is a reference to the inbox folder. Context.currentUser is the executing user not the owner of the Context.folder (s. Folder.systemUser)

after forwarding a file

Where to define Property at Filetype: afterForwardFileScript=Scriptname
Context.event workflow
return value No
Available properties Context.currentUser, Context.file, Context.workflowActionId, Context.workflowActionName, workflowErrorCode, workflowErrorMessage
This script exit will be called after a user has pressed a forward action in a workflow (only workflow engine, not distribution lists) and the forward action is completed.

on workflow action

Where to define Property at Filetype: onReceiveWorkflowActionScript=Scriptname
Context.event workflow
return value return value != 0 will abort the action
Available properties Context.currentUser, Context.file, Context.workflowActionId, Context.workflowActionName
This script exit will be called if a user presses an action in a workflow (only workflow engine, not distribution lists).

hide options for indirect forwarding

Where to define Property at filetype: hideForwardOptionScript=Scriptname
Context.event hideForwardOption
return value No
Available properties Context.currentUser, Context.file, Context.workflowStep, Context.workflowControlFlowId, enumval

This script exit allows you to hide the options ('Forward to' and 'Confer with') on the forwarding file dialog displayed after a user has pressed a indirect forwarding action in a workflow (only workflow engine, not distribution lists). Indirect forwarding is obtained by deselecting the 'Forward directly' option at the Control flow of the Action. The object enumval contains both options 'forwardTo' and 'conferWith'. Overwrite one with an empty string to hide the option on the forwarding file dialog.

var docFile = context.file;
if (!docFile)
return;
var currentUser = context.getSystemUser();
if (!currentUser)
{
enumval.clear();
throw "Error: currentUser == NULL";
}
for (var i=0; i<enumval.length; i++)
{
// Both options 'Forward to' and 'Confer with' should be hidden on the dialog.
if (enumval[i] == "forwardTo" || enumval[i] == "conferWith")
enumval[i] = ""
}

hide receivers for indirect forwarding

Where to define Property at filetype: hideForwardReceiverScript=Scriptname
Context.event hideForwardReceiver
return value No
Available properties Context.currentUser, Context.file, Context.workflowStep, Context.workflowControlFlowId, enumval

This script exit allows you to hide receivers on the forwarding file dialog displayed after a user has pressed a indirect forwarding action in a workflow (only workflow engine, not distribution lists). Indirect forwarding is obtained by deselecting the 'Forward directly' option at the Control flow of the Action. The object enumval contains all possible user login names and alias names. Overwrite a name with an empty string to hide the user or alias in the receiver list.

var docFile = context.file;
if (!docFile)
return;
var currentUser = context.getSystemUser();
if (!currentUser)
{
enumval.clear();
throw "Error: currentUser == NULL";
}
for (var i=0; i<enumval.length; i++)
{
// The user with login name 'user1' should be hidden in the receiver list.
if (enumval[i] == "user1")
enumval[i] = ""
}



E-Mail

after sending email

Where to define Property at Filetype: afterMailScript=Scriptname
Since 5.0
Context.event afterMail
return value none
Available properties Context.currentUser, Context.file, mailFrom, mailTo, mailCc, mailBcc, mailSubject, mailBody
This script exit will be called after an email is send by an user in the web client.

available blobs in email

Where to define Property at Filetype: mailAvailableBlobsScript=Scriptname
Since 5.0e
Context.event mailAvailableBlobs
return value none
Available properties Context.currentUser, Context.file, enumval

If a user wants to send a file as email in the web client, this exit will be called to modify the possible attachments, that are available to send. The enumval contains the documents-ids of the attachments of the file. It is possible to remove ids and to add ids e.g. from other files.

// Sample: Remove first document and add different one
if (context.event == "mailAvailableBlobs")
{
if (enumval.length > 0)
enumval.shift();
var otherFile = context.getFileById("dopaagfi_20180000000012");
try {
var doc = otherFile.getRegisters("documents").first().getDocuments().first();
enumval.push(doc.id)
} catch (err) {
util.out(err);
}
}



Check-in / Check-out

after check-in of a document

Where to define Property at Filetype: afterCheckInScript=Scriptname
Context.event
return value No
Available properties Context.currentUser, Context.file, documentOID, Context.workflowActionId, Context.workflowActionName
This script exit will be called after an user checked-in a document.

after canceling check-out

Where to define Property at Filetype: afterCancelCheckOutScript=Scriptname
Context.event onSave
return value No
Available properties Context.currentUser, Context.file, Context.workflowActionId, Context.workflowActionName, documentOID
This script exit will be called after an user cancels the check-out of a document.



Archive

on archiving a file

Where to define On register Scripting at Filetype: On archiving
Context.event onArchive
return value No
Available properties Context.currentUser, Context.file

This script exit will be called, when DOCUMENTS has got a request to store a file in an archive. It does not matter, if the request comes directly from the web interface, from a workflow step or from another script.

The object, which the exit passes to the script as Context.file, is either an active file or a modified file from the DOCUMENTS (EAS) archive. In the first case, the file is an original. In the second case it is a special kind of scratch copy, because archive files are immutable for the most part.

There is one special case, where this exit cannot be called: The internal SOAP-API method "createFile2" has got an option to create a file directly in EAS. This works completely without DocFiles, so the exit is bypassed.

after archiving a file

Where to define Property at Filetype: afterArchiveScript=ScriptName
Context.event afterArchive
return value No
Available properties Context.currentUser, Context.file, archiveErrorCode, archiveErrorMessage
This script exit will be called if a user archived a file.

after reactivating a file

Where to define Property at Filetype: afterReactivateScript=ScriptName
Context.event afterReactivate
return value No
Available properties Context.currentUser, Context.file
This script exit will be called if a user reactivates an archived file. At starting time of the script's execution, the file is not yet in edit mode.

on loading an archived file

Where to define Property at Filetype: onLoadArchiveFileScript=ScriptName
Context.event onLoadArchiveFile
return value No
Available properties Context.currentUser, Context.file
This script exit will be called when an archived file is loaded.



User

on login

Where to define Property at Principal: loginScript=Scriptname
Context.event onLogin
return value If the return value is != 0 the login will be denied.
Available properties login, asUser, source, instance, unit
This script exit will be called before the authorization against the system.

after login

Where to define Property at Principal: afterLoginScript=Scriptname
Context.event onLogin
return value No
Available properties login, asUser, source, instance, unit, Context.currentUser (since 5.0e HF2)
This script exit will be called after a successful login.

on login with single sign on

Where to define Property at Principal: autoLoginScript=Scriptname
Context.event autoLogin
return value No
Available properties login, source, instance, unit
This script exit will be called during a login with single sign on.

after login with single sign on

Where to define Property at Principal: afterAutoLoginScript=Scriptname
Context.event autoLogin
return value No
Available properties login, source, instance, unit, Context.currentUser (since 5.0e HF2)
This script exit will be called after a login with single sign on.

set password

Where to define Property at Principal: setPasswordScript=Scriptname
Context.event
return value If the return value is != 0 the password change will be canceled.
Available properties login, oldpassword, newpassword
This script exit will be called if an user wants to change his password. With the script you can define e.g. your own password guidelines. If the script returns a value != 0, the action will be canceled and the value of Context.errorMessage will be display in an alert window.

on logout

Where to define Property at Principal: logutScript=Scriptname
Context.event onLogout
return value No
Available properties Context.currentUser, source
This script exit will be called before the logout from the system. The source parameter contains the source of the logout e.g. "web" or "soapapi"

on EASY authentication

Where to define Property at Principal: EasyAuthScript=Scriptname
Context.event onEasyAuth
return value No
Available properties unit, instance, param.login, knownAccount, Context.currentUser (if available)

If the EASY Authentification feature is enabled, then this script exit will be called right before DOCUMENTS forwards login data to the archive. The script may overwrite the login name in param.login. The XML-Server will receive the modified login, but DOCUMENTS will internally still use the original login.
knownAccount indicates, if a Systemuser for the given login already exists. In this case the property Context.currentUser will refer to this object. Otherwise the value can be the job user or simply null.

// Sample: append country code to login against EASYWARE
param.login += "@de";
return 0;



Access rights

allowed actions

Where to define On register Scripting at filetype, register, folder Allowed actions
Context.event allowedActions
return value No
Available properties Context.currentUser, Context.file, enumval

If you specify user defined actions at the filetype, register or folder you can handle the access rights to the actions for a user. The object enumval contains the list of all actions. Overwrite an entry with an empty string to redraw a privilege.

// Sample: Withdraw user defined action "Release_Invoice"
var docFile = context.file;
if (!docFile)
return;
for (var i=0; i<enumval.length; i++)
{
if (enumval[i] == "Release_Invoice" && docFile.price > 10000)
enumval[i] = "";
}

decrease field right in file view

Where to define Property at filetype: decreaseFieldRightOnFileViewScript=Scriptname
Context.event decreaseFieldRights
return value No
Available properties Context.currentUser, Context.file, Context.register

This script exit allows you to redraw read and write rights on fields in the file view / edit mode.

var docFile = context.file;
if (!docFile)
return;
var currentUser = context.getSystemUser();
if (!currentUser)
{
enumval.clear();
throw "Error: currentUser == NULL";
}
// make field price:
// invisible for guest
// readonly for employee
// default for boss
var isBoss = currentUser.hasAccessProfile("Boss");
var isEmployee = currentUser.hasAccessProfile("Employee");
var guest = !isBoss && !isEmployee;
for (var i=0; i<enumval.length; i++)
{
if (enumval[i] == "price")
{
if (isBoss)
{
// do nothing - default right
}
else if (isEmployee)
{
enumval[i] = "-w"; // redraw write right
}
else
{
// isGuest
enumval[i] = "-rw"; // redraw read & write right
}
}
}

hide register in file view

Where to define Property at filetype: hideRegisterOnFileViewScript=Scriptname
Since 4.0c HF2
Context.event hideRegisters
return value No
Available properties Context.currentUser, Context.file

This script exit allows you to hide a register in the file view / edit mode. The object enumval contains the list of all register names. Overwrite a register name with an empty string to hide the register in the file view.

var docFile = context.file;
if (!docFile)
return;
var currentUser = context.getSystemUser();
if (!currentUser)
{
enumval.clear();
throw "Error: currentUser == NULL";
}
for (var i=0; i<enumval.length; i++)
{
// The registers 'reg1' und 'reg2' should be hidden in the file view.
if (enumval[i] == "reg1" || enumval[i] == "reg2")
enumval[i] = ""
}

decrease search archives

Where to define Property at Documents/Settings: decreaseSearchArchivesScript=Scriptname
Context.event decreaseSearchArchives
return value No
Available properties Context.currentUser, enumval

This script exit allows you to reduce the views in the extended search.

var publicViews = new Array();
publicViews.push("Unit=Default/Instance=Default/View=Scanners");
publicViews.push("Unit=Default/Instance=Default/View=Invoices");
var currentUser = context.getSystemUser();
if (!currentUser)
{
enumval.clear();
throw "Error: currentUser == NULL";
}
if (currentUser.hasAccessProfile("Boss"))
{
// Boss is authorized to see all view
return 0;
}
// disable all view, that are not public
for (var i=0; i<enumval.length; i++)
{
if (util.searchInArray(publicViews, enumval[i]) < 0)
enumval[i] = "";
}

decrease search stores

Where to define Property at Documents/Settings: decreaseSearchStoresScript=Scriptname
Context.event decreaseSearchStores
return value No
Available properties Context.currentUser, enumval

This script exit allows you to reduce the EDA and EBIS stores in the extended search. The enumval contains the names of the EDA and EBIS stores.

var publicStores = new Array();
publicStores.push("Invoice2016");
publicStores.push("Invoice2017");
var currentUser = context.getSystemUser();
if (!currentUser)
{
enumval.clear();
throw "Error: currentUser == NULL";
}
if (currentUser.hasAccessProfile("Boss"))
{
// Boss is authorized to see all stores
return 0;
}
// remove all stores, that are not public
for (var i=0; i<enumval.length; i++)
{
if (publicStores.indexOf(enumval[i]) < 0)
enumval[i] = "";
}

decrease search file types

Where to define Property at Documents/Settings: decreaseSearchFileTypesScript=Scriptname
Context.event decreaseSearchFileTypes
return value No
Available properties Context.currentUser, enumval

This script exit allows you to reduce the filetypes in the extended search. The enumval contains the names of the filetypes.

var confidentialFiletypes = new Array();
confidentialFiletypes.push("SecretLetters");
confidentialFiletypes.push("Salery");
var currentUser = context.getSystemUser();
if (!currentUser)
{
enumval.clear();
throw "Error: currentUser == NULL";
}
if (currentUser.hasAccessProfile("Boss"))
{
// Boss is authorized to search in all filetypes
return 0;
}
// remove all filetypes, that are confidential
for (var i=0; i<enumval.length; i++)
{
if (confidentialFiletypes.indexOf(enumval[i]) >= 0)
enumval[i] = "";
}

access script

Where to define Property at filetype: AccessScript=Scriptname
Context.event accessScript
return value No
Available properties Context.currentUser, Context.file, enumval

Such an AccessScript is executed every time read access to a file is attempted; it can check any conceivable condition (in doing so, it is imperative that you consider careful resource procedure, because this event is one of the extremely expensive resources!). An AccessScript provides four different rights in the form of the familiar array named enumval: "DlcFile_RightRead", "DlcFile_RightWrite", "DlcFile_RightChangeWorkflow" and "DlcFile_RightReactivate".

It is important to mention here that the read right from the AccessScript is actually more of a right, whether the file can be opened in the web.

var myFile = context.file;
if(!myFile)
throw "Not in a file context";
var read = "1";
var write = "0";
var changeWorkflow = "0";
var reactivate = "0";
var loginFileOwner = myFile.getAutoText("fileOwner.login");
var loginCurrentUser = context.currentUser;
if (loginFileOwner == loginCurrentUser)
write = "1";
for (var i = 0; i < enumval.length; i++)
{
switch (enumval[i])
{
case "DlcFile_RightRead":
enumval[i] = read;
break;
case "DlcFile_RightWrite":
enumval[i] = write;
break;
case "DlcFile_RightChangeWorkflow":
enumval[i] = changeWorkflow;
break;
case "DlcFile_RightReactivate":
enumval[i] = reactivate;
break;
}
}

hide mail template in file view

Where to define Property at filetype: allowedMailTemplatesScript=Scriptname
Context.event allowedMailTemplates
return value No
Available properties Context.currentUser, Context.file, enumval

This script exit allows you to hide a E-mail template in the file view. The object enumval contains the list of all E-mail template names. Overwrite a template name with an empty string to remove the E-mail template from the action list.

var docFile = context.file;
if (!docFile)
return;
var currentUser = context.getSystemUser();
if (!currentUser)
{
enumval.clear();
throw "Error: currentUser == NULL";
}
for (var i=0; i<enumval.length; i++)
{
// The E-mail template mailComplain should be hidden in the file view.
if (enumval[i] == "mailComplain")
enumval[i] = ""
}

hide print template in file view

Where to define Property at filetype: allowedPrintTemplatesScript=Scriptname
Context.event allowedPrintTemplates
return value No
Available properties Context.currentUser, Context.file, enumval

This script exit allows you to hide a print template in the file view. The object enumval contains the list of all print template names. Overwrite a template name with an empty string to remove the print template from the action list.

var docFile = context.file;
if (!docFile)
return;
var currentUser = context.getSystemUser();
if (!currentUser)
{
enumval.clear();
throw "Error: currentUser == NULL";
}
for (var i=0; i<enumval.length; i++)
{
// The print template invoiceTemplate should be hidden in the file view.
if (enumval[i] == "invoiceTemplate")
enumval[i] = ""
}

hide document template in edit mode

Where to define Property at filetype, register: allowedDocumentTemplatesScript=Scriptname
Context.event allowedDocumentTemplates
return value No
Available properties Context.currentUser, Context.file, enumval, (Context.register)

This script exit allows you to hide a document template at the register in the file edit mode. The object enumval contains the list of all document template names. Overwrite a template name with an empty string to remove the documents template from the register action list.

var docFile = context.file;
if (!docFile)
return;
var currentUser = context.getSystemUser();
if (!currentUser)
{
enumval.clear();
throw "Error: currentUser == NULL";
}
for (var i=0; i<enumval.length; i++)
{
// The document template letterComplain should be hidden in the edit mode.
if (enumval[i] == "letterComplain")
enumval[i] = ""
}



Document retrieval

on search request

Where to define Property at Documents/Settings: OnSearchScript=ScriptName
Since 4.0c HF2
Context.event onSearch
return value The return value must be an integer code, and it is usually zero. A negative value indicates an error and the search will subsequently be canceled. A few request types also allow a positive return value to indicate a warning message, which shall be displayed without cancelling the search. To avoid possible conflicts with existing codes, custom return codes should be in the range -1000 to -100 or +100 to +1000.
Available properties Context.currentUser, Context.file (only for dynamic register queries), Context.folderName (only for folder queries)
This script exit will be called when the DocumentsServer starts processing a search request. The exit can be used to cancel some requests with a custom error. Another possible use case is optimizing requests for a special project. See the class DocQueryParams for details and an example.

on preparation of a search formular

Where to define Property at Documents/Settings: FillSearchMaskScript=ScriptName
Since 4.0d
Context.event onFillSearchMask
return value None
Available properties Context.currentUser
This script exit will be called when DOCUMENTS is about to present a search formular to the user. The attached script can examine the selected search resources and available search fields. Subsequently it may place some default values in the search fields. It may also declare some of these values as write-protected.
The script should not perform lengthy tasks, because it will be called frequently.

A brief example:

var par = context.getQueryParams();
var cnt;
for(cnt = 0; cnt < par.searchFieldCount; ++cnt)
{
var feld = par.getSearchField(cnt, false);
if(feld.name == "hrSuperior")
feld.setDefault("schmidt", true);
}

modify support form

Where to define Script with defined prefix in script name: ScriptName must start with InfoDialogAddition
Since 5.0d HF1
Context.event supportInfo
return value None
Available properties and parameters Context.currentUser, param.supportInfoData
If the documents settings property HasSupportForm=1 is set, in the Client V is an info option to show and send a support form.
Before the support form is shown, the documents server searches for scripts that have the prefix InfoDialogAddition in there names. These scripts can modify the content of the form. This happens by modifying the Parameter param.supportInfoData. The Parameter contains the supportInfo as an JSON string.
JavaScript example
// Scriptname is "InfoDialogAdditionMysolution"
// Output param.supportInfoData:
var data = param.supportInfoData;
util.out(data);
// Set param.supportInfoData:
var obj = JSON.parse(data);
obj.suppFormMailTo = "support@mysolution.com";
param.supportInfoData = JSON.stringify(obj);
JSON example for param.supportInfoData
{
"suppForm": true,
"suppInfoHeader": "Systeminformationen",
"suppInfo": [
{
"Documents": "5.0d #2064 dbg x64 UTF-8 MS SQL Server\r\nAug 7 2018 - 2064.133939/J133931 branches/fixes/8.0d"
},
{
"Archive": "archiv: EAS eas-core-1.1.7-26 (develop)\r\nboost-1_59\r\nclucene-core-0.9.23\r\ncryptopp-562\r\nsqlite-3.19.2\r\nxerces-c-3.1.2\r\nOpenSSL 1.0.2k 26 Jan 2017\r\nICU-58.2\r\nmod_eas-1.1.7-26 (develop)\r\nlibapr-1.5.2\r\nlibapreq-2.8.1-dev\r\n"
},
{
"Host": "Doc5Dev11"
},
{
"OS": "Windows 7 (Service Pack 1)"
},
{
"CPU": "Intel(R) Xeon(R) CPU W3520 @ 2.67GHz - 4 Cores"
},
{
"DB": "Microsoft SQL Server 2014 - 12.0.2269.0 (X64) "
},
{
"Principal": "dopaag"
}
],
"suppFormHeader": "Support-Meldung",
"suppFormMailTo": {
"label": "E-Mail Support",
"value": "support@otris.de",
"readonly": true
},
"suppFormName": {
"label": "Kontakt",
"value": "Schreiber, Willi",
"readonly": false
},
"suppFormMailFrom": {
"label": "E-Mail",
"value": "schreiber@dopa.ag",
"readonly": false
},
"suppFormPhone": {
"label": "Telefonkontakt",
"value": "023112345-12",
"readonly": false
},
"suppFormSubject": {
"label": "Betreff der Anfrage",
"value": "",
"readonly": false
},
"suppFormMessage": {
"label": "Text der Anfrage",
"value": "",
"readonly": false
}
}




This documentation refers DOCUMENTS 5.0e (2105).
Created at 11-09-2019. - © 1998-2019 otris software AG, Königswall 21, D-44137 Dortmund. support@otris.de