DOCUMENTS 5 - PortalScripting API
Public Member Functions | Public Attributes | List of all members
DocFile Class Reference

The DocFile class implements the file object of DOCUMENTS. More...

Public Member Functions

boolean abort ()
 Cancel edit mode for a file. More...
 
Document addDocumentFromFileSystem (String pathDocument, String targetRegister, String targetFileName, boolean deleteDocumentAtFileSystem=false, boolean parseAutoText=false, DocFile referencFileToParse=this)
 Add a file as a new Document from the server's filesystem to a given Register. More...
 
boolean addPDF (String pathCoverXML, boolean createCover, String pdfFileName, String targetRegister, Array sourceRegisterNames)
 Create a PDF file containing the current DocFile's contents and store it on a given document register. More...
 
boolean archive ()
 Archive the DocFile object. More...
 
boolean archive (String archiveKey)
 Archive the DocFile object to the desired archive. More...
 
boolean archive (ArchivingDescription desc)
 Archive the DocFile object according to the given ArchivingDescription object. More...
 
boolean archiveAndDelete ()
 Archive the DocFile object and remove the DOCUMENTS file. More...
 
String asJSON (string[] fieldList=[])
 Creates a JSON-String of this file. More...
 
boolean cancelWorkflow ()
 Cancel the current workflow for the file. More...
 
boolean changeFiletype (String nameFiletype)
 Change the filetype of this file. More...
 
boolean checkWorkflowReceiveSignal ()
 Checks the receive signals of the workflow for the DocFile object. More...
 
boolean clearFollowUpDate (SystemUser pUser)
 Clear a followup date for a desired user. More...
 
boolean commit ()
 Commit any changes to the DocFile object. More...
 
boolean connectFolder (Folder fObj)
 Store a reference to the current file in the desired target folder. More...
 
int countFields (String fieldName)
 Count fields with a desired name in the file. More...
 
String createMonitorFile (boolean asPDF=false, String locale="")
 Creates a workflow monitor file in the server's file system. More...
 
String createStatusFile (boolean asPDF=false, String locale="")
 Creates a status file in the server's file system. More...
 
boolean deleteFile (boolean moveTrash=false, boolean movePool=true, boolean allVersions=false, integer easDeleteMode=0)
 Delete the DocFile object. More...
 
boolean disconnectArchivedFile ()
 Uncouple an active file from the archived version. More...
 
boolean disconnectFolder (Folder fObj)
 Remove a reference to the current file out of the desired target folder. More...
 
boolean exportXML (String pathXML, boolean withDocuments, boolean withStatus=false, boolean withMonitor=false)
 Export the file as an XML file. More...
 
boolean forwardFile (String controlFlowId, String comment="")
 Forward file in its workflow via the given control flow. More...
 
boolean fromJSON (String jsonstring)
 Updates a file from a JSON-String. More...
 
WorkflowStepIterator getAllLockingWorkflowSteps ()
 Get a list of all locking workflow step that currently lock the file. More...
 
WorkflowStepIterator getAllWorkflowSteps ()
 Get a list of all workflow step of the file. More...
 
String getArchiveKey (boolean withServer=true)
 After archiving of a file this method returns the key of the file in the archive. More...
 
String getAsPDF (String nameCoverTemplate, boolean createCover, Array sourceRegisterNames)
 Create a PDF file containing the current DocFile's contents and returns the path in the file system. More...
 
String getAttribute (String attribute)
 Get the String value of an attribute of the file. More...
 
String getAutoText (String autoText)
 Get the String value of a DOCUMENTS autotext. More...
 
DocFile getCopy ("NoDocs"|"ActualVersion"|"AllVersions" copyMode)
 Duplicate a file. More...
 
Date getCreationDate ()
 Returns the creation date (timestamp) of a DocFile. More...
 
var getCreator (boolean asObject=false)
 Returns the SystemUser object or fullname as String of the creator of the DocFile. More...
 
WorkflowStep getCurrentWorkflowStep ()
 Get the current workflow step of the current user locking the file. More...
 
DocFileDataField getDocFileComment ()
 Returns the comment value for a DocFile. More...
 
string [] getDoubleSelectListValues (String fieldName, boolean resolved=false)
 Get the enumeration values of the desired double select list field. More...
 
Array getEnumAutoText (String autoText)
 Get an array with the values of an enumeration autotext. More...
 
String getFieldAttribute (String fieldName, String attrName)
 Get the String value of an attribute of the desired file field. More...
 
String getFieldAutoText (String fieldName, String autoText="")
 Returns an AutoText value of a specified field of the DocFile. More...
 
String getFieldName (int index)
 Get the technical name of the n-th field of the file. More...
 
var getFieldValue (String fieldName, String returnType)
 Get the value of the desired file field. More...
 
SystemUser getFileOwner ()
 Get the file owner of the file. More...
 
WorkflowStep getFirstLockingWorkflowStep ()
 Get the first locking workflow step that currently locks the file. More...
 
String getid ()
 Returns the file id of the DocFile. More...
 
String getLastError ()
 Function to get the description of the last error that occurred. More...
 
Date getLastModificationDate ()
 Returns the last modification date (timestamp) of a DocFile. More...
 
String getLastModifier ()
 Returns the fullname as String of the last editor of the DocFile. More...
 
String getOID (boolean oidLow=false)
 Returns the object-id. More...
 
DocFile getOriginal ()
 Get the orginal file for a scratch copy. More...
 
DocFile getReferenceFile (String referenceFileField)
 Get the file referred by a reference field in the current file. More...
 
Register getRegisterByName (String registerName, boolean checkAccessRight=false)
 
RegisterIterator getRegisters (String type="documents", boolean checkAccessRight=false)
 Get an iterator with the registers of the file for the specified type. More...
 
String getTitle (String locale=user locale)
 Returns the title of the DocFile. More...
 
String getUserStatus (String login)
 Get the status of the file for a desired user. More...
 
boolean hasField (String fieldName)
 Gather information whether the current file has the field with the desired name. More...
 
boolean insertStatusEntry (String action, String comment)
 Add an entry to the status tab of the file. More...
 
boolean isArchiveFile ()
 Gather information whether the current file is an archive file. More...
 
boolean isDeletedFile ()
 Gather information whether the current file is a deleted file of a trash folder. More...
 
boolean isNewFile ()
 Gather information whether the current file is a new file. More...
 
boolean reactivate ()
 Reactivate an archive file to a file of the corresponding filetype. More...
 
boolean sendFileAdHoc (Array receivers, String sendMode, String task, boolean backWhenFinished)
 Send the DocFile directly. More...
 
boolean sendMail (String from, String templateName, String to, String cc, boolean addDocs, String bcc)
 Send the file as email to somebody. More...
 
boolean setAttribute (String attribute, String value)
 Set the String value of an attribute of the file to the desired value. More...
 
boolean setFieldAttribute (String fieldName, String attrName, String value)
 Set the value of an attribute of the desired file field. More...
 
boolean setFieldValue (String fieldName, var value)
 Set the value of the desired file field. More...
 
boolean setFileOwner (SystemUser owner)
 Set the file owner of the file to the desired user. More...
 
boolean setFollowUpDate (SystemUser pUser, Date followUpDate, String comment)
 Set a followup date for a desired user. More...
 
DocFile setReferenceFile (String fieldName, DocFile referenceFile)
 set the referred file of the desired reference field in the current file. More...
 
boolean setUserRead (String login, boolean fileRead)
 Mark the file as read or unread for the desired user. More...
 
boolean setUserStatus (String login, String status)
 Set the status of the file for a desired user to a desired value. More...
 
boolean startEdit ()
 Switch a DocFile to edit mode. More...
 
boolean startWorkflow (String workflowName)
 Start a workflow for the DocFile object. More...
 
boolean sync (boolean checkHistoryFields=false, boolean notifyHitlistChange=true, boolean updateRefFields=true, boolean updateModifiedDate=false)
 Synchronize any changes to the DocFile object back to the real file. More...
 
boolean undeleteFile ()
 Relive a deleted file. More...
 

Public Attributes

var fieldName
 The technical name of a field. More...
 

Detailed Description

The DocFile class implements the file object of DOCUMENTS.

You may access a single DocFile with the help of the attribute context.file or by creating a FileResultset. There are no special properties available, but each field of a file is mapped to an according property. You can access the different field values with their technical names.
For this reason it is mandatory to use programming language friendly technical names, meaning

Example:
var myFile = context.file;
var priority = myFile.Priority; // read a field value
myFile.Remark = "Just a remark"; // assign a value to a field
myFile.sync(); // apply changes in field values to the file

Member Function Documentation

◆ abort()

boolean DocFile::abort ( )

Cancel edit mode for a file.

If you switched a file to edit mode with the startEdit() method and if you want to cancel this (e.g. due to some error that has occurred in the mean time) this function should be used to destroy the scratch copy which has been created by the startEdit() instruction.

Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
Example:
var myFile = context.file;
myFile.startEdit();
myFile.Field = "value";
myFile.abort(); // effect: "value" is not applied!
See also
DocFile.startEdit()
DocFile.commit()

◆ addDocumentFromFileSystem()

Document DocFile::addDocumentFromFileSystem ( String  pathDocument,
String  targetRegister,
String  targetFileName,
boolean  deleteDocumentAtFileSystem = false,
boolean  parseAutoText = false,
DocFile  referencFileToParse = this 
)

Add a file as a new Document from the server's filesystem to a given Register.

It is possible to parse Autotexts inside the source file to fill the Document with the contents of index fields of a DocFile object. The max. file size for the source file is 512 KB.

Parameters
pathDocumentString value containing the complete filepath to the source file on the server
targetRegisterString value containing the technical name of the desired Register
targetFileNameString value containing the desired filename of the uploaded Document
deleteDocumentAtFileSystemoptional boolean value to decide whether to delete the source file on the server's filesystem
parseAutoTextoptional boolean value to decide whether to parse the AutoText values inside the source file. Note: if you want to make use of AutoTexts in this kind of template files, you need to use double percentage signs instead of single ones, e.g. %%Field1%% instead of %Field1%!
referencFileToParseoptional DocFile object to be used to parse the AutoTexts inside the template. If you omit this parameter, the current DocFile object is used as the data source.
Returns
Document if successful, null in case of any error
Since
ELC 3.51f / otrisPORTAL 5.1f
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var f = context.file;
var success = f.addDocumentFromFileSystem("c:\\temp\\test.rtf", "Documents", "parsedRTFFile.rtf", false, true);

◆ addPDF()

boolean DocFile::addPDF ( String  pathCoverXML,
boolean  createCover,
String  pdfFileName,
String  targetRegister,
Array  sourceRegisterNames 
)

Create a PDF file containing the current DocFile's contents and store it on a given document register.

The different document types of your documents on your different tabs require the appropriate PDF filter programs to be installed and configured in DOCUMENTS. To successfully add the created PDF file to a register the DocFile needs to be in edit mode (via startEdit() method), and the changes have to be applied via commit().

Parameters
pathCoverXMLString containing full path and filename of the template xml file to parse
createCoverboolean whether to create a field list or to only take the documents
pdfFileNameString value for the desired file name of the created PDF
targetRegisterString value containing the technical name of the target document register
sourceRegisterNamesArray with the technical names of the document registers you want to include
Returns
true if successful, false in case of any error
Since
ELC 3.50a / otrisPORTAL 5.0a
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var source = new Array();
source.push("FirstRegister");
source.push("SecondRegister");
var docFile = context.file;
docFile.startEdit();
docFile.addPDF("c:\\tmp\\cover.xml",
true,
"GeneratedPDF.pdf",
"MyTargetRegister",
source
);
docFile.commit();

◆ archive() [1/3]

boolean DocFile::archive ( )

Archive the DocFile object.

The target archive has to be configured in the filetype definition (in the Windows Portal Client) as the default archive. If no default archive is defined, the execution of this operation will fail.

Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
Example:
var myFile = context.file;
myFile.archive();

◆ archive() [2/3]

boolean DocFile::archive ( String  archiveKey)

Archive the DocFile object to the desired archive.

If the target archive key is misspelled or if the target archive does not exist, the operation will fall back to the default archive, as long as it is configured in the filetype definition. So the function will only fail if both the target archive and the default archive are missing.

Parameters
archiveKeyString value containing the complete archive key for EE.i or schema|view for EE.x of the desired target archive
Returns
true if successful, false in case of any error
Note
For EE.i: It is important to know that the target archive String must use the socalled XML-Server syntax. The old EAG syntax is not supported. It is as well neccessary to use a double backslash (\\) if you define your target archive as an ECMAScript String value, because a single backslash is a special character.
Since
EE.i: ELC 3.51c / otrisPORTAL 5.1c
EE.x: ELC 3.60a / otrisPORTAL 6.0a
EAS: Documents 4.0
Example:
// Example for EE.i:
var myFile = context.file;
var targetArchive = "$(#TOASTUP)\\STANDARD";
targetArchive += "@myeei"; // since Documents 4.0 using multi archive server
myFile.archive(targetArchive);
Example:
// Example for EE.x:
var myFile = context.file;
var view = "Unit=Default/Instance=Default/View=DeliveryNotes";
var schema = "Unit=Default/Instance=Default/DocumentSchema=LIEFERSCHEINE";
var target = schema + "|" + view;
target += "@myeex"; // since Documents 4.0 using multi archive server
myFile.archive(target);
Example:
// Example for EAS:
var myFile = context.file;
myFile.archive("@myeas"); // using multi archive server

◆ archive() [3/3]

boolean DocFile::archive ( ArchivingDescription  desc)

Archive the DocFile object according to the given ArchivingDescription object.

This is the most powerful way to archive a file through scripting, since the ArchivingDescription object supports a convenient way to influence which parts of the DocFile should be archived.

Parameters
descArchivingDescription object that configures several archiving options
Returns
true if successful, false in case of any error
Since
EE.i: ELC 3.51c / otrisPORTAL 5.1c
EE.x: ELC 3.60a / otrisPORTAL 6.0a
EAS: Documents 4.0
Example:
// Example for EE.i:
var myFile = context.file;
var ad = new ArchivingDescription();
ad.targetArchive = "$(#TOASTUP)\\STANDARD";
ad.archiveServer = "myeei"; // since Documents 4.0 using multi archive server
ad.archiveStatus = true;
ad.archiveMonitor = true;
ad.addRegister("all_docs"); // archive all attachments
var success = myFile.archive(ad);
if (success)
{
context.returnType = "html";
return ("<p>ArchiveFileID: " + myFile.getAttribute("Key") + "<p>");
}
Example:
// Example for EE.x:
var myFile = context.file;
var ad = new ArchivingDescription();
ad.targetView = "Unit=Default/Instance=Default/View=DeliveryNotes";
ad.targetSchema = "Unit=Default/Instance=Default/DocumentSchema=LIEFERSCHEINE";
ad.archiveServer = "myeex"; // since Documents 4.0 using multi archive server
ad.archiveStatus = true;
ad.archiveMonitor = true;
ad.addRegister("all_docs"); // archive all attachments
var success = myFile.archive(ad);
if (success)
{
context.returnType = "html";
return ("<p>ArchiveFileID: " + myFile.getArchiveKey() + "</p>");
}
Example:
// Example for EAS:
var myFile = context.file;
var ad = new ArchivingDescription();
ad.archiveServer = "myeas"; // using multi archive server
ad.archiveStatus = true;
ad.archiveMonitor = true;
ad.addRegister("all_docs"); // archive all attachments
var success = myFile.archive(ad);
if (success)
{
context.returnType = "html";
return ("<p>ArchiveFileID: " + myFile.getArchiveKey() + "</p>");
}
See also
ArchivingDescription

◆ archiveAndDelete()

boolean DocFile::archiveAndDelete ( )

Archive the DocFile object and remove the DOCUMENTS file.

The target archive has to be configured in the filetype definition (in the Windows Portal Client) as the default archive. It depends on the filetype settings as well, whether Status and Monitor will be archived as well. If no default archive is defined, the execution of this operation will fail.

Note
It is strictly forbidden to access the DocFile object after this function has been executed successfully; if you try to access it, your script will fail, because the DocFile does not exist any longer in DOCUMENTS. For the same reason it is strictly forbidden to execute this function in a signal exit PortalScript.
Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
Example:
var myFile = context.file;
myFile.archiveAndDelete();

◆ asJSON()

String DocFile::asJSON ( string []  fieldList = [])

Creates a JSON-String of this file.

Parameters
fieldListoptional String array, that specifies the DocFile attributes and field names, that will be part of JSON export

Available DocFile attributes:

  • "DlcFile_Title"
  • "DlcFile_Owner"
  • "DlcFile_Created"
  • "DlcFile_LastEditor"
  • "DlcFile_LastModified"
    Returns
    String with JSON content.
    Since
    DOCUMENTS 5.0 HF1
    DOCUMENTS 5.0c HF2 (new parameter fieldList)
    Example:
    var file = context.file;
    util.out(file.asJSON());
    // {
    // "DlcFile_Title": "Filetype1_Test 11.03.2011 11:23",
    // "DlcFile_Owner": "user1",
    // "DlcFile_Created": "2011-03-11T10:23:00.000Z",
    // "DlcFile_LastEditor": "user2",
    // "DlcFile_LastModified": "2011-03-12T18:08:08.000Z",
    // "str":"Hallo",
    // "ts":"2015-11-20T13:21:22.389Z", Zulu Time
    // "bool":true,
    // "num":1,
    // "float":3.14,
    // "arr":["abc",1,true]
    // }
    var file = context.file;
    var fields = ["DlcFile_Title", "str"];
    util.out(file.asJSON(fields));
    // {
    // "DlcFile_Title": "Filetype1_Test 11.03.2011 11:23",
    // "str":"Hallo"
    // }
    See also
    DocFile.fromJSON(String jsonstring)

◆ cancelWorkflow()

boolean DocFile::cancelWorkflow ( )

Cancel the current workflow for the file.

Returns
true if successful, false in case of any error
Since
ELC 3.51e / otrisPORTAL 5.1e
Example:
var f = context.file;
f.cancelWorkflow();

◆ changeFiletype()

boolean DocFile::changeFiletype ( String  nameFiletype)

Change the filetype of this file.

Parameters
nameFiletypeString containing the technical name of the filetype.
Returns
true if successful, false in case of any error.
Since
DOCUMENTS 4.0e
Example:
var file = context.file;
if (!file.changeFiletype("newFiletype"))
util.out(file.getLastError());

◆ checkWorkflowReceiveSignal()

boolean DocFile::checkWorkflowReceiveSignal ( )

Checks the receive signals of the workflow for the DocFile object.

This method can only be used for a DocFile, that runs in a workflow and the workflow has receive signals. Usually the receive signals of the workflow step will be checked by a periodic job. Use this method to trigger the check of the receive signals for the DocFile.

Returns
true if successful, false in case of any error
Since
DOCUMENTS 4.0a
Example:
var myFile = context.file;
var succ = myFile.checkWorkflowReceiveSignal();
if (!succ)
util.out(myFile.getLastError());

◆ clearFollowUpDate()

boolean DocFile::clearFollowUpDate ( SystemUser  pUser)

Clear a followup date for a desired user.

Parameters
pUserSystemUser object of the desired user
Returns
true if successful, false in case of any error
Since
ELC 3.51b / otrisPORTAL 5.1b
Example:
var docFile = context.file;
var su = context.getSystemUser();
docFile.clearFollowUpDate(su);
See also
DocFile.setFollowUpDate(SystemUser pUser, Date followUpDate, String comment)

◆ commit()

boolean DocFile::commit ( )

Commit any changes to the DocFile object.

This method is mandatory to apply changes to a file that has been switched to edit mode with the startEdit() method. It is strictly prohibited to execute the commit() method in a script which is attached to the onSave scripting hook.

Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
Example:
var myFile = context.file;
myFile.startEdit();
myFile.Field = "value";
myFile.commit();
See also
DocFile.startEdit()
DocFile.sync()
DocFile.abort()

◆ connectFolder()

boolean DocFile::connectFolder ( Folder  fObj)

Store a reference to the current file in the desired target folder.

The (public) folder must be a real folder, it must not be a dynamic filter, nor a "only subfolder" object.

Parameters
fObjFolder object representing the desired target public folder
Returns
true if successful, false in case of any error.
Since
ELC 3.51h / otrisPORTAL 5.1h
Example:
var f = context.file;
var fObj = context.getFoldersByName("Invoices").first();
var success = f.connectFolder(fObj);
See also
DocFile.disconnectFolder(Folder fObj)

◆ countFields()

int DocFile::countFields ( String  fieldName)

Count fields with a desired name in the file.

Parameters
fieldNameString containing the technical name of the fields to be counted.
Returns
The number of fields als an Integer.
Note
When this function is called on an EE.x DocFile with an empty field name, the return value may be greater than expected. The DOCUMENTS image of such a file can include EE.x system fields and symbolic fields for other imported scheme attributes (blob content, notice content).
Since
DOCUMENTS 4.0c HF2
Example:
var key = "Unit=Default/Instance=Default/Pool=DEMO/Pool=RECHNUNGEN/Document=RECHNUNGEN.41D3694E2B1E11DD8A9A000C29FACDC2@eex1"
var docFile = context.getArchiveFile(key);
if (!docFile)
throw "archive file does not exist: " + key;
else
util.out(docFile.countFields("fieldName"));

◆ createMonitorFile()

String DocFile::createMonitorFile ( boolean  asPDF = false,
String  locale = "" 
)

Creates a workflow monitor file in the server's file system.

This method creates a monitor file in the server's file system with the workflow monitor content of the DocFile. The file will be created as a html-file.

Parameters
asPDFboolean parameter that indicates that a pdf-file must be created instead of a html-file
localeString (de, en,..) in which locale the file must be created (empty locale = log-in locale)
Returns
String containing the path of the created file
Note
This generated file will no be automatically added to the DocFile
Since
DOCUMENTS 4.0a HF2

◆ createStatusFile()

String DocFile::createStatusFile ( boolean  asPDF = false,
String  locale = "" 
)

Creates a status file in the server's file system.

This method creates a status file in the server's file system with the status content of the DocFile. The file will be created as a html-file.

Parameters
asPDFboolean parameter that indicates that a pdf-file must ge created instead of a html-file
localeString (de, en,..) in which locale the file must be created (empty locale = log-in locale)
Returns
String containing the path of the created file
Note
This generated file will no be automatically added to the DocFile
Since
DOCUMENTS 4.0a HF2

◆ deleteFile()

boolean DocFile::deleteFile ( boolean  moveTrash = false,
boolean  movePool = true,
boolean  allVersions = false,
integer  easDeleteMode = 0 
)

Delete the DocFile object.

If there's another PortalScript attached to the onDelete scripting hook, it will be executed right before the deletion takes place.

Note
It is strictly forbidden to access the DocFile object after this function has been executed successfully; if you try to access it, your script will fail, because the DocFile does not exist any longer in DOCUMENTS. For the same reason it is strictly forbidden to execute this function in a signal exit PortalScript.
Parameters
moveTrashoptional boolean parameter to decide whether to move the deleted file to the trash folder
movePooloptional boolean parameter to decide whether to move the deleted file's object to the file pool
allVersionsoptional boolean parameter to delete all versions of an EAS archive file at once.
easDeleteModeopional integer specifying the delete mode for an EAS archive file. See remarks.
Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
ELC 3.50n / otrisPORTAL 5.0n (moveTrash parameter)
ELC 3.51f / otrisPORTAL 5.1f (movePool parameter)
DOCUMENTS 4.0a HF1 (available for archive files)
DOCUMENTS 4.0e (all versions)
DOCUMENTS 5.0e (easDeleteMode)
Note
The parameters moveTrash, movePool are ignored for archive files. The parameters allVersions and easDeleteMode require an EAS/EDA file and are ignored otherwise.
Remarks
The parameter easDeleteMode is interpreted in the following way. 0 = Use default setting (property "EASDeleteMode" of the archive store or factory setting); 1 = quick delete (restorable from WORM directory with archive administration tools); 2 = full delete (requires archive maintenance login "eas_keeper"). The last option ist occasionally needed to make a solution compliant with EU-GDPR. If a script tries to delete the actual "context.file", the server usually enforces "movePool = true". This is controlled by the common DOCUMENTS property "ContextFileDeleteProtection".
Example:
var myFile = context.file;
myFile.deleteFile(false, true);

◆ disconnectArchivedFile()

boolean DocFile::disconnectArchivedFile ( )

Uncouple an active file from the archived version.

Returns
true if successful, false in case of any error.
Since
DOCUMENTS 4.0d
Example:
var f = context.file;
var f.archive();
var success = f.disconnectArchivedFile();
See also
DocFile.archive(), DocFile.getArchiveKey(boolean withServer)

◆ disconnectFolder()

boolean DocFile::disconnectFolder ( Folder  fObj)

Remove a reference to the current file out of the desired target folder.

The (public) folder must be a real folder, it must not be a dynamic filter, nor a "only subfolder" object.

Parameters
fObjFolder object representing the desired target public folder
Returns
true if successful, false in case of any error.
Since
ELC 3.51h / otrisPORTAL 5.1h
Example:
var f = context.file;
var fObj = context.getFoldersByName("Invoices").first();
var success = f.disconnectFolder(fObj);
See also
DocFile.connectFolder(String folderName)

◆ exportXML()

boolean DocFile::exportXML ( String  pathXML,
boolean  withDocuments,
boolean  withStatus = false,
boolean  withMonitor = false 
)

Export the file as an XML file.

Parameters
pathXMLString containing full path and filename of the desired target xml file
withDocumentsboolean value to include the documents. The value must be set to true in case status or monitor information are to be inserted.
withStatusboolean value to include status information. The value must be set to true in order to add the status. Status Information will then be generated into a file which will be added to the documents. Please note that therefore withDocuments must be set to true in order to get Status information.
withMonitorboolean value to include Monitor information. The value must be set to true in order to add the monitor. Monitor Information will then be generated into a file which will be added to the documents. Please note that therefore withDocuments must be set to true in order to get Monitor information.
Returns
true if successful, false in case of any error
Since
ELC 3.50a / otrisPORTAL 5.0a
ELC 3.60e / otrisPORTAL 6.0e (Option: export of status & monitor)
Example:
var docFile = context.file;
docFile.exportXML("c:\\tmp\\myXmlExport.xml", true, false, true);

◆ forwardFile()

boolean DocFile::forwardFile ( String  controlFlowId,
String  comment = "" 
)

Forward file in its workflow via the given control flow.

This method only works if the file is inside a workflow and inside a workflow action that is accessible by a user of the web interface. Based on that current workflowstep you need to gather the ID of one of the outgoing control flows of that step. The access privileges of the current user who tries to execute the script are taken into account. Forwarding the file will only work if that control flow is designed to forward without query.

Note
This function requires a full workflow engine license, it does not work with pure submission lists.
Parameters
controlFlowIdString containing the technical ID of the outgoing control flow that should be passed
commentoptional String value containing a comment to be automatically added to the file's monitor
Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
Example:
var docFile = context.file;
var step = docFile.getCurrentWorkflowStep();
var flowId = step.firstControlFlow;
docFile.forwardFile(flowId);

◆ fromJSON()

boolean DocFile::fromJSON ( String  jsonstring)

Updates a file from a JSON-String.

Must be followed by sync()

Returns
true if successful, false in case of any error.
Since
DOCUMENTS 5.0 HF1
See also
DocFile.asJSON()

◆ getAllLockingWorkflowSteps()

WorkflowStepIterator DocFile::getAllLockingWorkflowSteps ( )

Get a list of all locking workflow step that currently lock the file.

The locking workflow steps do not need to be locked by the current user executing the script, this function as well returns all locking steps which refer to different users.

Note
This function requires a full workflow engine license, it does not work with pure submission lists.
Returns
WorkflowStepIterator object which represents a list of all locking workflow steps for the file
Since
ELC 3.51e / otrisPORTAL 5.1e
Example:
var f = context.file;
var stepIter = f.getAllLockingWorkflowSteps();
if (stepIter.size() > 0)
util.out("File is locked by " + stepIter.size() + " workflow steps");
See also
DocFile.getCurrentWorkflowStep()
DocFile.getFirstLockingWorkflowStep()

◆ getAllWorkflowSteps()

WorkflowStepIterator DocFile::getAllWorkflowSteps ( )

Get a list of all workflow step of the file.

The methd will return all workflow steps, the currently locking and the previous ones.

Note
This function requires a full workflow engine license, it does not work with pure submission lists.
Returns
WorkflowStepIterator object which represents a list of all workflow steps for the file
Since
DOCUMENTS 5.0b
Example:
var f = context.file;
var stepIter = f.getAllWorkflowSteps();
See also
DocFile.getCurrentWorkflowStep()
DocFile.getFirstLockingWorkflowStep()

◆ getArchiveKey()

String DocFile::getArchiveKey ( boolean  withServer = true)

After archiving of a file this method returns the key of the file in the archive.

Parameters
withServeroptional boolean value to indicate, if the key should include an "@archiveServerName" appendix
Returns
String containing the key.
Note
If the file is not archived or archived without versioning or uncoupled from the achived file the key is empty.
Since
ELC 3.60a / otrisPORTAL 6.0a
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var f = context.file;
if (f.archive())
util.out(f.getArchiveKey());
else
util.out(f.getLastError());
See also
DocFile.archive(), DocFile.disconnectArchivedFile()

◆ getAsPDF()

String DocFile::getAsPDF ( String  nameCoverTemplate,
boolean  createCover,
Array  sourceRegisterNames 
)

Create a PDF file containing the current DocFile's contents and returns the path in the file system.

The different document types of your documents on your different tabs require the appropriate PDF filter programs to be installed and configured in DOCUMENTS.

Parameters
nameCoverTemplateString containing the name of the pdf cover template defined at the filetype
createCoverboolean whether to create a field list or to only take the documents
sourceRegisterNamesArray with the technical names of the document registers you want to include
Returns
String with file path of the pdf, an empty string in case of any error
Since
DOCUMENTS 4.0b
Example:
var source = new Array();
source.push("FirstRegister");
source.push("SecondRegister");
var docFile = context.file;
var pathPdfFile = docFile.getAsPDF("pdfcover", true, source);
if (pathPdfFile == "")
throw docFile.getLastError();
util.out("Size: " + util.fileSize(pathPdfFile))

◆ getAttribute()

String DocFile::getAttribute ( String  attribute)

Get the String value of an attribute of the file.

Parameters
attributeString containing the name of the desired attribute
Returns
String containing the value of the desired attribute
Since
ELC 3.50 / otrisPORTAL 5.0
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var myFile = context.file;
util.out(myFile.getAttribute("hasInvoicePlugin"));

◆ getAutoText()

String DocFile::getAutoText ( String  autoText)

Get the String value of a DOCUMENTS autotext.

Parameters
autoTextthe rule to be parsed
Returns
String containing the parsed value of the autotext
Since
ELC 3.50 / otrisPORTAL 5.0
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var myFile = context.file;
util.out(myFile.getAutoText("fileOwner"));

◆ getCopy()

DocFile DocFile::getCopy ( "NoDocs"|"ActualVersion"|"AllVersions"  copyMode)

Duplicate a file.

This function creates a real 1:1 copy of the current file which may be submitted to its own workflow. The function returns the copied file. If an error occurrs, the function returns null and getLastError() can be called on the calling object.

Parameters
copyModedefines how to handle the documents of the originating file.
There are three different parameter values allowed:
  • "NoDocs" copied DocFile does not contain any documents
  • "ActualVersion" copied DocFile contains only the latest (published) version of each document
  • "AllVersions" copied DocFile contains all versions (both published and locked) of each document
Returns
DocFile object representing the copied file, null in case of error
Since
ELC 3.51c / otrisPORTAL 5.1c
Example:
var docFile = context.file;
var newFile = docFile.getCopy("AllVersions");
if (!newFile)
util.out(docFile.getLastError());

◆ getCreationDate()

Date DocFile::getCreationDate ( )

Returns the creation date (timestamp) of a DocFile.

Returns
Date object, if the date is valid, null for an invalid data.
Since
DOCUMENTS 5.0c
Example:
var file = context.file;
var c_ts = file.getCreationDate();
if (c_ts)
util.out(c_ts);
See also
DocFile.getCreator(boolean asObject)
DocFile.getLastModificationDate()

◆ getCreator()

var DocFile::getCreator ( boolean  asObject = false)

Returns the SystemUser object or fullname as String of the creator of the DocFile.

Parameters
asObjectoptional boolean value, that specifies, if the SystemUser object or the fullname should be returned.
Returns
asObject=true: SystemUser object or null (if user does not exist anymore)
asObject=false: String with the fullname.
Since
DOCUMENTS 5.0c
Example:
var file = context.file;
var su = file.getCreator(true);
if (su)
util.out(su.login);
else
util.out(file.getCreator());
See also
DocFile.getLastModifier()
DocFile.getCreationDate()

◆ getCurrentWorkflowStep()

WorkflowStep DocFile::getCurrentWorkflowStep ( )

Get the current workflow step of the current user locking the file.

The function returns a valid WorkflowStep object if there exists one for the current user. If the current user does not lock the file, the function returns null instead.

Note
This function requires a full workflow engine license, it does not work with pure submission lists.
Returns
WorkflowStep object
Since
ELC 3.51e / otrisPORTAL 5.1e
Example:
var f = context.file;
var step = f.getCurrentWorkflowStep();
if (!step)
step = f.getFirstLockingWorkflowStep();
// still no workflow steps found? File not in workflow
if (!step)
util.out("File is not in a workflow");
See also
DocFile.getFirstLockingWorkflowStep()

◆ getDocFileComment()

DocFileDataField DocFile::getDocFileComment ( )

Returns the comment value for a DocFile.

Returns
DocFileDataField object or null.
Since
DOCUMENTS 5.0d

◆ getDoubleSelectListValues()

string [] DocFile::getDoubleSelectListValues ( String  fieldName,
boolean  resolved = false 
)

Get the enumeration values of the desired double select list field.

Parameters
fieldNameString containing the technical field name can be followed by the desired instance number in form techFieldName[i] for multi-instance fields of an EE.i/EE.x archive file.
Note: The index i is zero-based. The specification of field instance is olny available for an EE.i/EE.x archive file, it will be ignored for other files. If the parameter contains no instance information, the first field instance is used. The field instance order is determined by the field order in the file.
resolvedOptional boolean value indicating whether to return the full multi language enumeration values (e.g. "key;de:Wert;en:Value") instead of only the keys (e.g. "key"). The default value is false.
Returns
Array of strings containing the multi language enumeration values or only the keys.
Since
DOCUMENTS 5.0e HF2
Example:
var myFile = context.file;
var values = myFile.getDoubleSelectListValues("DoubleListfield", true);
if (values)
{
for (var i = 0; i < values.length; i++)
{
util.out(values[i]);
}
}

◆ getEnumAutoText()

Array DocFile::getEnumAutoText ( String  autoText)

Get an array with the values of an enumeration autotext.

Parameters
autoTextto be parsed
Returns
Array containing the values for the autotext
Since
ELC 3.60e / otrisPORTAL 6.0e
Example:
var values = context.getEnumAutoText("%accessProfile%")
if (values)
{
for (var i=0; i < values.length; i++)
{
util.out(values[i]);
}
}

◆ getFieldAttribute()

String DocFile::getFieldAttribute ( String  fieldName,
String  attrName 
)

Get the String value of an attribute of the desired file field.

Parameters
fieldNameString containing the technical name of the desired field
attrNameString containing the name of the desired attribute
Returns
String containing the value of the desired field attribute
Since
ELC 3.50 / otrisPORTAL 5.0
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var myFile = context.file;
util.out(myFile.getFieldAttribute("Samplefield", "Value"));

◆ getFieldAutoText()

String DocFile::getFieldAutoText ( String  fieldName,
String  autoText = "" 
)

Returns an AutoText value of a specified field of the DocFile.

The following AutoTexts are available

  • "[locale]" - field value in the user locale or specified locale.
  • "key" - key value (e.g. at refence fields, enumeration fields, etc.).
  • "fix" - fix format value (e.g. at numeric fields, date fields, etc.).
  • "pos" - order position of the field value at enumeration fields.
  • "raw" - database field value.
  • "label[.locale]" - label of the field in user locale or specified locale.
Parameters
fieldNameName of the field as String
[autoText]WantedAutoText as String (default = "" returns field value in the user locale)
Returns
String with the AutoText.
Since
DOCUMENTS 5.0c
Example:
var file = context.file;
util.out(file.getFieldAutoText("erpInvoiceDate")); // => 31.12.2017
util.out(file.getFieldAutoText("erpInvoiceDate", "en")); // => 12/31/2017
util.out(file.getFieldAutoText("erpInvoiceDate", "fix")); // => 20171231
util.out(file.getFieldAutoText("erpInvoiceDate", "label")); // => Rechnungsdatum
util.out(file.getFieldAutoText("erpInvoiceDate", "label.en")); // => Invoice date

◆ getFieldName()

String DocFile::getFieldName ( int  index)

Get the technical name of the n-th field of the file.

This allows generic scripts to be capable of different versions of the same filetype, e.g. if you changed details of the filetype, but there are still older files of the filetype in the system.

Parameters
indexinteger index of the desired field
Returns
String containing the technical name of the file field, false if index is out of range
Since
ELC 3.50e / otrisPORTAL 5.0e
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var myFile = context.file;
var fieldName = "Samplefield";
var fields = new Array();
var i = 0;
// get all field names
while (myFile.getFieldName(i))
{
fields[i] = myFile.getFieldName(i)
i++;
}
// check for field existance
var found = false;
for (var j = 0; j < fields.length; j++)
{
if (fields[j] == fieldName)
{
found = true;
break;
}
}

◆ getFieldValue()

var DocFile::getFieldValue ( String  fieldName,
String  returnType 
)

Get the value of the desired file field.

Parameters
fieldNameString containing the technical field name can be followed by the desired instance number in form techFieldName[i] for multi-instance fields of an EE.i/EE.x archive file.
Note: The index i is zero-based. The specification of field instance is olny available for an EE.i/EE.x archive file, it will be ignored for other files. If the parameter contains no instance information, the first field instance is used. The field instance order is determined by the field order in the file.
returnTypeOptional string specified the type of the return value. Currently only the type "Array" is available for a double select list field.
Returns
The field value, its type depends on the field type (such as a Date object returned for a field of type 'Timestamp') or the specified return type if applicable.
See also
Field Access Methods
Since
DOCUMENTS 4.0c
DOCUMENTS 4.0c HF2 available for multi-instance fields of an EE.i/EE.x archive file
DOCUMENTS 5.0e HF2 (optional parameter returnType)
Example:
var myFile = context.file;
util.out(myFile.getFieldValue("Samplefield"));
// Since DOCUMENTS 4.0c HF2
var key = "Unit=Default/Instance=Default/Pool=FeldZ/Document=Feldzahlen.86C94C30438011E2B925080027B22D11@eex1";
var eexFile = context.getArchiveFile(key);
util.out(eexFile.getFieldValue("multiInstanceField[2]"));
// Since DOCUMENTS 5.0e HF2
var myFile = context.file;
var values = myFile.getFieldValue("doubleListfield", "Array");
if (values)
{
for (var i = 0; i < values.length; i++)
{
util.out(values[i]);
}
}

◆ getFileOwner()

SystemUser DocFile::getFileOwner ( )

Get the file owner of the file.

Returns
SystemUser object representing the user who owns the file
Since
ELC 3.51d / otrisPORTAL 5.1d
Example:
var docFile = context.file;
var su = docFile.getFileOwner();
util.out(su.login);

◆ getFirstLockingWorkflowStep()

WorkflowStep DocFile::getFirstLockingWorkflowStep ( )

Get the first locking workflow step that currently locks the file.

The first locking workflow step does not need to be locked by the current user executing the script, this function as well returns the first locking step if it is locked by a different user. If no locking step is found at all, the function returns null instead.

Note
This function requires a full workflow engine license, it does not work with pure submission lists.
Returns
WorkflowStep object
Since
ELC 3.50e / otrisPORTAL 5.0e
Example:
var f = context.file;
var step = f.getCurrentWorkflowStep();
if (!step)
{
step = f.getFirstLockingWorkflowStep();
}
// still no workflow steps found? File not in workflow
if (!step)
{
util.out("File is not in a workflow");
}
See also
DocFile.getCurrentWorkflowStep()

◆ getid()

String DocFile::getid ( )

Returns the file id of the DocFile.

Returns
String with the file id.
Since
DOCUMENTS 5.0c
Example:
var file = context.file;
util.out(file.getid());

◆ getLastError()

String DocFile::getLastError ( )

Function to get the description of the last error that occurred.

Returns
Text of the last error as String
Since
ELC 3.50 / otrisPORTAL 5.0
Example:
var myFile = context.file;
// do something which may go wrong
if (hasError)
{
util.out(myFile.getLastError());
}

◆ getLastModificationDate()

Date DocFile::getLastModificationDate ( )

Returns the last modification date (timestamp) of a DocFile.

Returns
Date object, if the date is valid, null for an invalid data.
Since
DOCUMENTS 5.0c
Example:
var file = context.file;
var c_ts = file.getLastModificationDate();
if (c_ts)
util.out(c_ts);
See also
DocFile.getLastModifier()
DocFile.getCreationDate()

◆ getLastModifier()

String DocFile::getLastModifier ( )

Returns the fullname as String of the last editor of the DocFile.

Returns
String with the fullname.
Since
DOCUMENTS 5.0c
Example:
var file = context.file;
util.out(file.getLastModifier());
See also
DocFile.getCreator(boolean asObject)
DocFile.getLastModificationDate()

◆ getOID()

String DocFile::getOID ( boolean  oidLow = false)

Returns the object-id.

Parameters
oidLowOptional flag:
If true only the id of the DocFile object (m_oid) will be returned.
If false the id of the DocFile object will be returned together with the id of the corresponding class in the form class-id:m_oid.
The default value is false.
Returns
String with the object-id
Since
ELC 3.60c / otrisPORTAL 6.0c
ELC 3.60i / otrisPORTAL 6.0i available for archive files
DOCUMENTS 5.0 (new parameter oidLow)

◆ getOriginal()

DocFile DocFile::getOriginal ( )

Get the orginal file for a scratch copy.

If you run a scipt on a scratch copy (e.g. a onSave script), you can get the orginal file with this function.

Returns
DocFile
Since
DOCUMENTS 4.0 (EAS)
Example:
var scratchCopy = context.file;
var origFile = scratchCopy.getOriginal();
if (!origFile)
util.out(scratchFile.getLastError();
else
{
if (scratchCopy.FieldA != origFile.FieldA)
util.out("Field A changed");
else
util.out("Field A not changed");
}

◆ getReferenceFile()

DocFile DocFile::getReferenceFile ( String  referenceFileField)

Get the file referred by a reference field in the current file.

If the current file's filetype is connected to a superior filetype by a reference field, this function allows to easily access the referred file, e.g. if you are in an invoice file and you want to access data of the referring company.

Parameters
referenceFileFieldString value containing the technical name of the file field contianing the definition to the referred filetype
Returns
DocFile object representing the referred file if successful, null in case of any error
Since
ELC 3.51c / otrisPORTAL 5.1c
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var docFile = context.file;
var company = docFile.getReferenceFile("crmCompany");
util.out(company.crmCompanyName);

◆ getRegisterByName()

Register DocFile::getRegisterByName ( String  registerName,
boolean  checkAccessRight = false 
)
Parameters
registerNameString value containing the technical name of the desired register
checkAccessRightoptional boolean value, that indicates if the access rights should be considered.
Returns
Register object representing the desired register
Since
ELC 3.50n / otrisPORTAL 5.0n
ELC 3.60i / otrisPORTAL 6.0i available for archive files
DOCUMENTS 5.0c (new optional parameter checkAccessRight)
Note
Until version 5.0c this method ignored the access rights of the user to the register. With the optional parameter checkAccessRight this can now be done. For backward compatibility the default value is set to false.
Example:
var docFile = context.file;
var reg = docFile.getRegisterByName("Documents");
See also
DocFile.getRegisters(String type, boolean checkAccessRight)

◆ getRegisters()

RegisterIterator DocFile::getRegisters ( String  type = "documents",
boolean  checkAccessRight = false 
)

Get an iterator with the registers of the file for the specified type.

Parameters
typeoptional String value to filter for a desired register type. Default type is documents
Allowed values:
  • documents
  • fields
  • links
  • archiveddocuments
  • externalcall
  • all (returns all registers independent of the type)
checkAccessRightoptional boolean value, that indicates if the access rights should be considered.
Returns
RegisterIterator with all registers (matching the filter)
Since
ELC 3.50n / otrisPORTAL 5.0n
ELC 3.60i / otrisPORTAL 6.0i available for archive files
DOCUMENTS 5.0c (new optional parameter checkAccessRight)
Note
Until version 5.0c this method ignored the access rights of the user to the register. With the optional parameter checkAccessRight this can now be done. For backward compatibility the default value is set to false.
Example:
var docFile = context.file;
var regIter = docFile.getRegisters("documents");
See also
RegisterIterator
DocFile.getRegisterByName(String registerName, boolean checkAccessRight)

◆ getTitle()

String DocFile::getTitle ( String  locale = user locale)

Returns the title of the DocFile.

Parameters
[locale]Locale as String (default = user locale)
Returns
String with the title.
Since
DOCUMENTS 5.0c
Note
the special locale raw returns the title in all locales
Example:
var file = context.file;
util.out(file.getTitle("en"));

◆ getUserStatus()

String DocFile::getUserStatus ( String  login)

Get the status of the file for a desired user.

Parameters
loginString containing the login name of the desired user
Returns
String with the status. Possible values:
  • standard
  • new
  • fromFollowup
  • toForward
  • forInfo
  • task
  • workflowCanceled
  • backFromDistribution
  • consultation
Since
DOCUMENTS 4.0c HF1
Example:
var docFile = context.file;
util.out(docFile.getUserStatus("schreiber"));
See also
DocFile.setUserStatus(String login, String status)

◆ hasField()

boolean DocFile::hasField ( String  fieldName)

Gather information whether the current file has the field with the desired name.

Parameters
fieldNameString containing the technical name of the field.
Returns
true if the file has the field, false if not
Since
DOCUMENTS 4.0d
Example:
var file = context.file;
if (file.hasField("address"))
util.out(file.address);

◆ insertStatusEntry()

boolean DocFile::insertStatusEntry ( String  action,
String  comment 
)

Add an entry to the status tab of the file.

This function is especially useful in connection with PortalScripts being used as decision guards in workflows, because this allows to comment and describe the decisions taken by the scripts. This increases transparency concerning the life cycle of a file in DOCUMENTS.

Parameters
actionString containing a brief description
commentoptional String containing a descriptive comment to be added to the status entry
Returns
true if successful, false in case of any error
Since
ELC 3.51b / otrisPORTAL 5.1b
Example:
var docFile = context.file;
docFile.insertStatusEntry("Executed Guard Script","all conditions met");

◆ isArchiveFile()

boolean DocFile::isArchiveFile ( )

Gather information whether the current file is an archive file.

Returns
true if is an archive file, false if not
Since
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var key = "Unit=Default/Instance=Default/Pool=DEMO/Pool=RECHNUNGEN/Document=RECHNUNGEN.41D3694E2B1E11DD8A9A000C29FACDC2"
var docFile = context.getArchiveFile(key);
if (docFile)
util.out(docFile.isArchiveFile());

◆ isDeletedFile()

boolean DocFile::isDeletedFile ( )

Gather information whether the current file is a deleted file of a trash folder.

Returns
true if is a deleted file, false if not
Since
ELC 3.60e / otrisPORTAL 6.0e
Example:
...
var trashFolder = user.getPrivateFolder("trash");
if (trashFolder)
{
var it = trashFolder.getFiles();
for (var file = it.first(); file; file = it.next())
{
if (file.isDeletedFile())
util.out("ok");
else
util.out("Error: Found undeleted file in trash folder!");
}
}

◆ isNewFile()

boolean DocFile::isNewFile ( )

Gather information whether the current file is a new file.

Returns
true if new file, false if not
Since
ELC 3.50l01 / otrisPORTAL 5.0l01
Example:
var docFile = context.file;
util.out(docFile.isNewFile());

◆ reactivate()

boolean DocFile::reactivate ( )

Reactivate an archive file to a file of the corresponding filetype.

Returns
true if successful, false if not - get error message with getLastError()
Since
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var key = "Unit=Default/Instance=Default/Pool=DEMO/Pool=RECHNUNGEN/Document=RECHNUNGEN.41D3694E2B1E11DD8A9A000C29FACDC2@eex1"
var docFile = context.getArchiveFile(key);
if (!docFile)
throw "archive file does not exist: " + key;
if (!docFile.reactivate())
throw "Reactivation failed: " + docFile.getLastError();
docFile.startWorkflow....

◆ sendFileAdHoc()

boolean DocFile::sendFileAdHoc ( Array  receivers,
String  sendMode,
String  task,
boolean  backWhenFinished 
)

Send the DocFile directly.

Parameters
receiversArray with the names of the users or groups to which to send the DocFile. You need to specify at least one recipient.
sendModeString containing the send type. The following values are available:
  • sequential - one after the other
  • parallel_info - concurrently for information
taskString specifying the task for the recipients of the DocFile
backWhenFinishedboolean indicating whether the DocFile should be returned to the own user account after the cycle.
Returns
true if successful, false in case of any error.
Since
DOCUMENTS 5.0
Example:
var docFile = context.createFile("Filetype1");
var success = docFile.sendFileAdHoc(["user2", "user3"], "parallel_info", "test task", true);
if (!success)
util.out(docFile.getLastError());

◆ sendMail()

boolean DocFile::sendMail ( String  from,
String  templateName,
String  to,
String  cc,
boolean  addDocs,
String  bcc 
)

Send the file as email to somebody.

You must define an email template in the Windows Portal Client at the filetype of your DocFile object. This template may contain autotexts that can be parsed and replaced with their appropriate field values.

Parameters
fromString value containing the sender's email address
templateNameString value containing the technical name of the email template. This must be defined on the email templates tab of the filetype.
toString value containing the email address of the recipient
ccOptional String value for an additional recipient ("cc" means "carbon copy")
addDocsoptional boolean value whether to include the documents of the file
bccOptional String value for the email addresses of blind carbon-copy recipients (remaining invisible to other recipients).
Returns
true if successful, false in case of any error
Since
ELC 3.50b / otrisPORTAL 5.0b
ELC 3.60i / otrisPORTAL 6.0i available for archive files
DOCUMENTS 4.0d new parameter bcc
Example:
var docFile = context.file;
docFile.sendMail("schreiber@toastup.de", "MyMailTemplate",
"oppen@toastup.de", "", true
);

◆ setAttribute()

boolean DocFile::setAttribute ( String  attribute,
String  value 
)

Set the String value of an attribute of the file to the desired value.

Parameters
attributeString containing the name of the desired attribute
valueString containing the desired value of the attribute
Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var myFile = context.file;
myFile.setAttribute("hasInvoicePlugin", "true");

◆ setFieldAttribute()

boolean DocFile::setFieldAttribute ( String  fieldName,
String  attrName,
String  value 
)

Set the value of an attribute of the desired file field.

Parameters
fieldNameString containing the technical name of the desired field
attrNameString containing the name of the desired attribute
valueString value containing the desired field attribute value
Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
ELC 3.60i / otrisPORTAL 6.0i available for archive files
Example:
var myFile = context.file;
myFile.setFieldAttribute("Samplefield", "Value", "1");

◆ setFieldValue()

boolean DocFile::setFieldValue ( String  fieldName,
var  value 
)

Set the value of the desired file field.

Parameters
fieldNameString containing the technical field name can be followed by the desired instance number in form techFieldName[i] for multi-instance fields of an EE.i/EE.x archive file.
Note: The index i is zero-based. The specification of field instance is only available for an EE.i/EE.x archive file, it will be ignored for other files. If the parameter contains no instance information, the first field instance is used. The field instance order is determined by the field order in the file.
valueThe desired field value of the proper type according to the field type, e.g. a Date object as value of a field of type 'Timestamp'.
Note: The keys of the enumeration values for a double select list field may be passed either as an Array of strings or as an ordinary string with one key per line of text (see Field Access Methods).
Returns
true if successful, false in case of any error.
Since
DOCUMENTS 4.0c
DOCUMENTS 4.0c HF2 available for multi-instance fields of an EE.i/EE.x archive file
DOCUMENTS 5.0c HF2 String array as value for a double select list field
Example:
var myFile = context.file;
myFile.setFieldValue("NumericField", 3.14);
myFile.setFieldValue("TimestampField", new Date());
myFile.setFieldValue("BoolField", true);
myFile.setFieldValue("StringField", "Hello");
myFile.setFieldValue("DoubleListField1", "key1\nkey2";
myFile.setFieldValue("DoubleListField2", ["key1", "key2"]; // Since DOCUMENTS 5.0e HF2
myFile.sync();
// Since DOCUMENTS 4.0c HF2
var key = "Unit=Default/Instance=Default/Pool=FeldZ/Document=Feldzahlen.86C94C30438011E2B925080027B22D11@eex1";
var eexFile = context.getArchiveFile(key);
eexFile.startEdit();
eexFile.setFieldValue("multiInstanceField[2]", "Hello");
eexFile.commit();

◆ setFileOwner()

boolean DocFile::setFileOwner ( SystemUser  owner)

Set the file owner of the file to the desired user.

Parameters
ownerSystemUser object representing the desired new file owner
Returns
true if successful, false in case of any error
Since
ELC 3.51d / otrisPORTAL 5.1d
Example:
var docFile = context.file;
var su = context.getSystemUser();
docFile.setFileOwner(su);

◆ setFollowUpDate()

boolean DocFile::setFollowUpDate ( SystemUser  pUser,
Date  followUpDate,
String  comment 
)

Set a followup date for a desired user.

Parameters
pUserSystemUser object of the desired user
followUpDateDate object representing the desired followup date
commentoptional String value containing a comment that is displayed as a task as soon as the followup is triggered
Returns
true if successful, false in case of any error
Since
ELC 3.51b / otrisPORTAL 5.1b
Example:
var docFile = context.file;
var su = context.getSystemUser();
var followup = util.convertStringToDate("31.12.2008", "dd.mm.yyyy");
docFile.setFollowUpDate(su, followup, "Silvester");
See also
DocFile.clearFollowUpDate(SystemUser pUser)

◆ setReferenceFile()

DocFile DocFile::setReferenceFile ( String  fieldName,
DocFile  referenceFile 
)

set the referred file of the desired reference field in the current file.

Parameters
fieldNameString value containing the technical name of the reference field
referenceFileDocFile object representing the referred file
Returns
true if successful, false in case of any error
Since
DOCUMENTS 5.0e
Example:
var docFile = context.file;
var refFile = context.createFile("refFileType");
if (!docFile.setReferenceFile("crmCompany", refFile))
util.out(docFile.getLastError());

◆ setUserRead()

boolean DocFile::setUserRead ( String  login,
boolean  fileRead 
)

Mark the file as read or unread for the desired user.

Note
This function requires a full workflow engine license, it does not work with pure submission lists.
Parameters
loginString containing the login name of the desired user
fileReadboolean whether the file should be markes as read (true) or unread (false)
Returns
true if successful, false in case of any error
Since
ELC 3.50b / otrisPORTAL 5.0b
Example:
var docFile = context.file;
docFile.setUserRead("schreiber", true);

◆ setUserStatus()

boolean DocFile::setUserStatus ( String  login,
String  status 
)

Set the status of the file for a desired user to a desired value.

The file icon in the list view and file view depends on this status.

Parameters
loginString containing the login name of the desired user
statusString value containing the desired status
Allowed values:
  • standard
  • new
  • fromFollowup
  • toForward
  • forInfo
  • task
  • workflowCanceled
  • backFromDistribution
  • consultation
Returns
true if successful, false in case of any error
Since
ELC 3.50b / otrisPORTAL 5.0b
DOCUMENTS 4.0c (status values extended)
Example:
var docFile = context.file;
docFile.setUserStatus("schreiber", "new");
See also
DocFile.getUserStatus(String login)

◆ startEdit()

boolean DocFile::startEdit ( )

Switch a DocFile to edit mode.

Switching a file to edit mode with this function has the same effect as the "Edit" button in the web surface of DOCUMENTS. This means, a scratch copy of the file is created, and any changes you apply to the file are temporarily stored in the scratch copy - until you commit() your changes back to the original file. There are a few scripting event hooks which disallow the use of this function at all costs:

  • onEdit hook - the system has already created the scratch copy.
  • onCreate hook - a newly created file is always automatically in edit mode.

You should avoid using this function in scripts that are executed inside a workflow (signal exits, decisions etc.).

Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
Example:
var myFile = context.file;
myFile.startEdit();
myFile.Field = "value";
myFile.commit(); // apply changes
See also
DocFile.abort(), DocFile.commit()

◆ startWorkflow()

boolean DocFile::startWorkflow ( String  workflowName)

Start a workflow for the DocFile object.

Parameters
workflowNameString containing the technical name and optional the version number of the workflow. The format of the workflowName is technicalName[-version]. If you don't specify the version of the workflow, the workflow with the highest workflow version number will be used. If you want to start a specific version you have to use technicalName-version e.g. (Invoice-2) as workflowName.
Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
Example:
var myFile = context.file;
myFile.startWorkflow("Invoice"); // starts the latest version of the workflow "Invoice"
myFile.startWorkflow("Invoice-2"); // starts the version 2 of the workflow "Invoice"

◆ sync()

boolean DocFile::sync ( boolean  checkHistoryFields = false,
boolean  notifyHitlistChange = true,
boolean  updateRefFields = true,
boolean  updateModifiedDate = false 
)

Synchronize any changes to the DocFile object back to the real file.

If you want to apply changes to file fields through a script that is executed as a signal exit inside a workflow, you should rather prefer sync() than the startEdit() / commit() instruction pair.

Note
If there's a scratch copy of the file in the system (e.g. by some user through the web surface), committing the changes in the scratch copy results in the effect that your synced changes are lost. So be careful with the usage of this operation.
In case of an error, the function stops immediately, regardless of how many values were already written to the database. So if sync() finishes due to an error, the file will probably contain some but not all new values. If you change field values using setFieldValue(), you can get the errors before you call sync().
Parameters
checkHistoryFieldsoptional boolean parameter has to be set to true, if the file contains history fields, that are modified
notifyHitlistChangeoptional boolean parameter indicates the web client to refresh the current hitlist
updateRefFieldsoptional boolean parameter indicates to update reference fields if using the property AutoUpdateByRefFields
updateModifiedDateoptional boolean parameter indicates to update the modification date of the file
Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0 (checkHistoryFields parameter since ELC 3.60i / otrisPORTAL 6.0i)
DOCUMENTS 5.0a (new parameter updateRefFields)
DOCUMENTS 5.0a HF2 (new parameter updateModifiedDate)
Example:
var myFile = context.file;
myFile.Field = "value";
myFile.sync();
See also
DocFile.startEdit()
DocFile.commit()
DocFile.setFieldValue()

◆ undeleteFile()

boolean DocFile::undeleteFile ( )

Relive a deleted file.

Sets the status active to a file and redraws it from the trash folder. Deleted files are not searchable by a FileResultSet. You can only retrieve deleted files by iterating throw the trash-folder of the users

Returns
true if successful, false if not
Since
ELC 3.60e / otrisPORTAL 6.0e
Example:
...
var trashFolder = user.getPrivateFolder("trash");
if (trashFolder)
{
var it = trashFolder.getFiles();
for (var file = it.first(); file; file = it.next())
{
if (file.isDeletedFile())
{
file.undeleteFile();
// now e.g. search a private folder and add the file...
}
}
}

Member Data Documentation

◆ fieldName

var DocFile::fieldName

The technical name of a field.

Each field of a DocFile is mapped to an according property. You can access the field value with the technical name.

Returns
The field value, its type depends on the field type, such as a Date object returned for a field of type 'Timestamp'.
Since
ELC 3.50 / otrisPORTAL 5.0
Example:
var myFile = context.file;
var strValue = myFile.stringField;
myFile.dateField = new Date();
myFile.sync();

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