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

The DocHit class presents the hit object collected by a HitResultset. More...

Public Member Functions

DocFile getArchiveFile ()
 Get a file from the archive associated to the archive hit. More...
 
String getArchiveKey (boolean withServer=true)
 Retrieve the key of the associated archive file object. More...
 
String getBlobInfo ()
 Function to get the blob info of the hit as xml. More...
 
DocFile getFile ()
 Get the file associated to the hit. More...
 
String getFileId ()
 Get the file id of the associated file object. More...
 
String getLastError ()
 Function to get the description of the last error that occurred. More...
 
String getLocalValue (int colIndex)
 Get the local value of an available column. More...
 
String getLocalValueByName (String colName)
 Get the local value of an available column. More...
 
String getSchema ()
 Get a schema identifier of the archive hit. More...
 
String getTechValue (int colIndex)
 Get the technical value of an available column. More...
 
String getTechValueByName (String colName)
 Get the technical value of an available column. More...
 
boolean isArchiveHit ()
 Function to test whether the associated file is an archive file. More...
 

Public Attributes

var columnName
 Field value, addressed by a known column name. More...
 

Detailed Description

The DocHit class presents the hit object collected by a HitResultset.

Objects of this class cannot be created directly. You may access a single DocHit by creating a HitResultset, which provides functions to retrieve its hit entries.

Since
DOCUMENTS 4.0b
Example:
var searchResource = "Standard";
var filter = "";
var sortOrder = "";
var myFile;
var myHRS = new HitResultset(searchResource, filter, sortOrder);
for (var myHit = myHRS.first(); myHit; myHit = myHRS.next())
{
if (myHit.isArchiveHit())
myFile = myHit.getArchiveFile();
else
myFile = myHit.getFile();
if (myFile)
util.out(myFile.getAutoText("title"));
else
util.out(myHit.getLastError());
}
See also
HitResultset.first(), HitResultset.next()
HitResultset.getAt(number pos), HitResultset.fetchNextPage()

Member Function Documentation

◆ getArchiveFile()

DocFile DocHit::getArchiveFile ( )

Get a file from the archive associated to the archive hit.

You need the necessary access rights on the archive side.

Returns
DocFile or NULL, if failed.
Remarks
This function creates a complete DOCUMENTS image of the archived file, except for the content of attachments. This is a time-consuming workstep. If a script calls this function for each hit in the set, it will not run any faster than a script, which uses a conventional ArchiveFileResultset instead of this class.
Since
DOCUMENTS 4.0b
See also
getFile()

◆ getArchiveKey()

String DocHit::getArchiveKey ( boolean  withServer = true)

Retrieve the key of the associated archive file object.

Parameters
withServeroptional boolean value to indicate, if the key should include an "@archiveServerName" appendix
Returns
The archive file's key as a String, but an empty String, if the hit does not refer to an archive file.
Since
DOCUMENTS 4.0b
See also
getFileId()

◆ getBlobInfo()

String DocHit::getBlobInfo ( )

Function to get the blob info of the hit as xml.

Returns
String with xml content
Since
DOCUMENTS 5.0c

◆ getFile()

DocFile DocHit::getFile ( )

Get the file associated to the hit.

If the file does not exist or the user in whose context the script is executed is not allowed to access the file, then the return value will be NULL.

Returns
DocFile or NULL, if failed.
Since
DOCUMENTS 4.0b
See also
getArchiveFile()

◆ getFileId()

String DocHit::getFileId ( )

Get the file id of the associated file object.

Returns
The file id as String, if the associated file is an active file, but an empty String otherwise.
Since
DOCUMENTS 4.0b
See also
getArchiveKey(boolean withServer)

◆ getLastError()

String DocHit::getLastError ( )

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

Returns
Text of the last error as String
Since
DOCUMENTS 4.0b

◆ getLocalValue()

String DocHit::getLocalValue ( int  colIndex)

Get the local value of an available column.

Parameters
colIndexThe zero-based index of the column.
Returns
The local value of the given column as String.
Since
DOCUMENTS 4.0b
See also
getLocalValueByName(String colName)

◆ getLocalValueByName()

String DocHit::getLocalValueByName ( String  colName)

Get the local value of an available column.

Parameters
colNameThe name of the column.
Returns
The local value of the given column as String.
Note
Accesing a column by its index is a bit faster than by its name.
Since
DOCUMENTS 4.0b
See also
getLocalValue(int colIndex)

◆ getSchema()

String DocHit::getSchema ( )

Get a schema identifier of the archive hit.

Returns
The schema identifier as a String.
Remarks
For EE.i, the value is an archive identifier in the XML-Server's notation. For EDA it is just the name of a filetype. All values come with an "@Servername" appendix.
Since
DOCUMENTS 4.0b

◆ getTechValue()

String DocHit::getTechValue ( int  colIndex)

Get the technical value of an available column.

Parameters
colIndexThe zero-based index of the column.
Returns
The technical value of the given column as a String.
Remarks
The function returns dates, timestamps and numbers in DOCUMENTS' storage format. (In the DOCUMENTS Manager see menu 'Documents/Settings', dialog page 'Locale/format', group 'Format settings'.) If you prefer JavaScript numbers and dates, simply use the object like an array: myDocHit[colIndex].
Since
DOCUMENTS 4.0b
See also
getTechValueByName(String colName)

◆ getTechValueByName()

String DocHit::getTechValueByName ( String  colName)

Get the technical value of an available column.

Parameters
colNameThe name of the column.
Returns
The technical value of the given column as String.
Note
Accessing a column by its index is a bit faster than by its name.
Remarks
The function returns dates, timestamps and numbers in DOCUMENTS' storage format. (In the DOCUMENTS Manager see menu 'Documents/Settings', dialog page 'Locale/format', group 'Format settings'.) If you prefer JavaScript numbers and dates, you can simply read the columns as a property DocHit.columnName.
Since
DOCUMENTS 4.0b
See also
getTechValue(int colIndex), DocHit.columnName

◆ isArchiveHit()

boolean DocHit::isArchiveHit ( )

Function to test whether the associated file is an archive file.

Returns
true, if the associated file is an archive file, false otherwise.
Since
DOCUMENTS 4.0b

Member Data Documentation

◆ columnName

var DocHit::columnName

Field value, addressed by a known column name.

Each field in a DocHit is mapped to an according property. You can read the value on the basis of the column name.

Returns
The field value; its type depends on the field type, such as a Date object returned for a column of type 'Timestamp'.
Remarks
Overwriting values in a DocHit is not allowed. Each attempt will raise an exception. To read dates and numbers in DOCUMENTS' storage format, see getTechValueByName().
Since
DOCUMENTS 5.0HF2
Example:
function logValue(label, value)
{
util.out(label +" [" + typeof(value) + "] " + value);
}
var HRS = new HitResultset("ftOrder", "", "", "HL2");
var hitline = HRS.first();
if(hitline)
{
// We assume, "ftOrder" has got a string field "company", a
// date field "orderDate" and a numeric field "netPrice".
var checkVal = hitline.company;
logValue("company: ", checkVal);
checkVal = hitline.orderDate;
logValue("orderDate: ", checkVal);
// The next example shows a different way to read "hitline.netPrice".
// This style is necessary, if the name of a column contains
// critical characters, or if the name equals a reserved JavaScript keyword.
checkVal = hitline["netPrice"];
logValue("orderDate: ", checkVal);
// Columns can also be addressed by number (0..n-1)
checkVal = hitline[0];
logValue("first column: ", checkVal);
}

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