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

This class allows asynchronous calling a script from another script. More...

Public Member Functions

boolean addParameter (String name, String value)
 Add a parameter to the called script. More...
 
string [] getEnumval ()
 Get the return enumval value of the called script. More...
 
String getLastError ()
 Get the description of the last error that occurred. More...
 
String getReturnValue ()
 Get the return value of the called script. More...
 
boolean isFinished ()
 Check whether the script call was finished. More...
 
boolean isRunning ()
 Check whether the script call is actually running. More...
 
boolean launch ()
 Launch the script call. More...
 
ScriptCall ScriptCall (Var systemUser, String scriptName, boolean waitable)
 Create a new ScriptCall object. More...
 
boolean setDocFile (DocFile docFile)
 Set the execution context file of the called script. More...
 
boolean setDocument (Document doc)
 Set the execution context document of the called script. More...
 
boolean setEvent (String scriptEvent)
 Set the execution context event of the called script. More...
 
boolean setFolder (Folder folder)
 Set the execution context folder of the called script. More...
 
boolean setRegister (Register register)
 Set the execution context register of the called script. More...
 
boolean setRunAsEnumScript (boolean runAsEnumScript)
 Let the called script run as an enumeration script. More...
 
boolean waitForFinish ()
 Wait for the script call to finish. More...
 

Detailed Description

This class allows asynchronous calling a script from another script.

You should deliberate whether a script call can be waitable or not. Only waitable script calls can be managed e.g. waiting for a script call to finish or checking whether a call is still running.

Since
DOCUMENTS 4.0d

Constructor & Destructor Documentation

◆ ScriptCall()

ScriptCall ScriptCall::ScriptCall ( Var  systemUser,
String  scriptName,
boolean  waitable 
)

Create a new ScriptCall object.

The following properties of the execution context of the called script are carried over from the execution context of the script where this ScriptCall object is created:

  • file
  • register
  • document
  • event

You can change these context properties with the available set-methods.

Parameters
systemUserThe system user who triggers execution of the called script and can be specified as follows:
  • String containing the login name of the system user.
  • SystemUser object representing the system user.
scriptNameString with the name of the called script.
waitableboolean flag indicating whether this script call is waitable.
Since
DOCUMENTS 4.0d

Member Function Documentation

◆ addParameter()

boolean ScriptCall::addParameter ( String  name,
String  value 
)

Add a parameter to the called script.

Parameters
nameString value containing the parameter name.
valueString value containing the parameter value.
Returns
true if successful, false in case of any error
Since
DOCUMENTS 5.0
Example:
var call = new ScriptCall("schreiber", "testScript", false);
call.addParameter("testParam", "testValue");

◆ getEnumval()

string [] ScriptCall::getEnumval ( )

Get the return enumval value of the called script.

Note
This function is only available for a waitable ScriptCall.
Returns
The return value as an array if the waitable ScriptCall was successfully completed, otherwise the string "Undefined".
Since
DOCUMENTS 5.0 HF2
Example:
var call = new ScriptCall("schreiber", "myEnumScript", true);
if (call.launch())
{
if (call.waitForFinish())
util.out(call.getEnumval());
}

◆ getLastError()

String ScriptCall::getLastError ( )

Get the description of the last error that occurred.

Returns
Text of the last error as String
Example:
var call = new ScriptCall("schreiber", "testScript", true);
if (!call.launch())
util.out(call.getLastError());

◆ getReturnValue()

String ScriptCall::getReturnValue ( )

Get the return value of the called script.

Note
This function is only available for a waitable ScriptCall.
Returns
The return value as String if the waitable ScriptCall was successfully completed, otherwise the string "Undefined".
Since
DOCUMENTS 5.0
Example:
var call = new ScriptCall("schreiber", "testScript", true);
if (call.launch())
{
if (call.waitForFinish())
util.out(call.getReturnValue());
}

◆ isFinished()

boolean ScriptCall::isFinished ( )

Check whether the script call was finished.

Note
This function is only available for a waitable script call.
Returns
true if the script call is finished, otherwise false
Since
DOCUMENTS 5.0e HF2
Example:
var call = new ScriptCall("schreiber", "testScript", true);
if (!call.launch())
throw call.getLastError();
while (!call.isFinished())
{
// do something different
}
// Call is finished and result is available
return call.getReturnValue();
See also
ScriptCall.isRunning

◆ isRunning()

boolean ScriptCall::isRunning ( )

Check whether the script call is actually running.

Actually running means, that the script will be executed at this moment (other states are new or queued)

Note
This function is only available for a waitable script call.
Returns
true if the script call is running, otherwise false
Since
DOCUMENTS 4.0d
Example:
var call = new ScriptCall("schreiber", "testScript", true);
if (call.launch())
{
if (call.isRunning())
{
// do something
}
}
See also
ScriptCall.isFinished

◆ launch()

boolean ScriptCall::launch ( )

Launch the script call.

In case of successful launch the script will be executed in an own context.

Returns
true if successful, false in case of any error
Since
DOCUMENTS 4.0d
Example:
var call = new ScriptCall("schreiber", "testScript", true);
if (!call.launch())
util.out(call.getLastError());

◆ setDocFile()

boolean ScriptCall::setDocFile ( DocFile  docFile)

Set the execution context file of the called script.

Parameters
docFileDocFile object representing the desired execution context file.
Returns
true if successful, false in case of any error
Since
DOCUMENTS 4.0d
Example:
var user = context.findSystemUser("schreiber");
var call = new ScriptCall(user, "testScript", true);
var file = context.getFileById("peachit_fi20120000000016");
if (file)
call.setDocFile(file);
See also
Context.file

◆ setDocument()

boolean ScriptCall::setDocument ( Document  doc)

Set the execution context document of the called script.

Parameters
docDocument object representing the desired execution context document.
Returns
true if successful, false in case of any error
Since
DOCUMENTS 4.0d
Example:
var call = new ScriptCall("schreiber", "testScript", false);
var file = context.getFileById("peachit_fi20120000000016");
if (file)
{
var reg = file.getRegisterByName("Doc1");
if (reg)
{
var it = reg.getDocuments();
if (it.size() > 0)
call.setDocument(it.first());
}
}
See also
Context.document

◆ setEvent()

boolean ScriptCall::setEvent ( String  scriptEvent)

Set the execution context event of the called script.

Parameters
scriptEventString value containing the desired script event of the execution context.
Returns
true if successful, false in case of any error
Since
DOCUMENTS 4.0d
Example:
var call = new ScriptCall("schreiber", "testScript", false);
call.setEvent("onArchive");
See also
Context.event

◆ setFolder()

boolean ScriptCall::setFolder ( Folder  folder)

Set the execution context folder of the called script.

Parameters
folderFolder object representing the desired execution context folder.
Returns
true if successful, false in case of any error
Since
DOCUMENTS 5.0d
Example:
var call = new ScriptCall("schreiber", "testScript", false);
call.setFolder(context.folder);
See also
Context.folder

◆ setRegister()

boolean ScriptCall::setRegister ( Register  register)

Set the execution context register of the called script.

Parameters
registerRegister object representing the desired execution context register.
Returns
true if successful, false in case of any error
Since
DOCUMENTS 4.0d
Example:
var call = new ScriptCall("schreiber", "testScript", false);
var file = context.getFileById("peachit_fi20120000000016");
if (file)
{
var reg = file.getRegisterByName("Doc1");
call.setRegister(reg);
}
See also
Context.register

◆ setRunAsEnumScript()

boolean ScriptCall::setRunAsEnumScript ( boolean  runAsEnumScript)

Let the called script run as an enumeration script.

The global parameter enumval is then available in the called script

Parameters
runAsEnumScriptboolean value.
Since
DOCUMENTS 5.0 HF2
Example:
var call = new ScriptCall(context.getSystemUser(), "myEnumScript", true);
call.setRunAsEnumScript(true);
if (!call.launch())
throw call.getLastError();
call.waitForFinish();
util.out(call.getEnumval());
See also
ScriptCall.getEnumval()

◆ waitForFinish()

boolean ScriptCall::waitForFinish ( )

Wait for the script call to finish.

Note
This function is only available for a waitable script call.
Returns
true if successful, false in case of any error
Since
DOCUMENTS 4.0d
Example:
var call = new ScriptCall("schreiber", "testScript", true);
if (call.launch())
{
if (call.waitForFinish())
{
// do something
}
else
util.out(call.getLastError());
}

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