Constructor
new $k.Script(optionsopt)
Create a new script element
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | <optional> | Options object Properties
|
- Since
- 6.2
If creating a new script is not allowed
If the optional ID is not valid (e.g. another element is already registered)
Extends
Methods
callFunction(name, functionArguments) → {any}
Calls a function that is defined in the script
| Name | Type | Description |
|---|---|---|
name | string | The name of a function defined in the script |
functionArguments | Array.<any> | Array of arguments passed to the function |
- Since
- 5.8.3
If the script does not define a function with the given name
- Type
- UndeclaredFunctionError
The return value of the evaluated function
- Type:
- any
deregister()
Deregisters the element. The ID will be undefined afterwards. Equivalent to setId(undefined)
- Inherited From
- See
- setId
jsDocNoAdminRights
eval() → {any}
Evaluates the script. Equivalent to eval(source())
- Since
- 5.4.2
The return value of the evaluated script
- Type:
- any
id() → {string|undefined}
Returns the registered ID, or undefined if not registered.
- Inherited From
- Type:
- string |
undefined
module() → {object}
Returns the module exports of the script
- Since
- 5.4.2
If this script is not registered
- Type:
- object
name() → {string}
Returns the name of the element
- Since
- 6.1.1
- Inherited From
- Type:
- string
parentFolders() → {Array.<$k.Folder>}
Returns the folders that contain this element
- Inherited From
- Type:
- Array.<$k.Folder>
register(replaceScriptReferencesopt) → {string}
Registers the element with a private ID, if it has no registered ID yet.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
replaceScriptReferences | boolean | <optional> | false | True if ID references in scripts should be replaced. Only done when the old and the new ID is not undefined. |
- Since
- 6.1.1
- Inherited From
jsDocNoAdminRights
The registered ID
- Type:
- string
registryType() → {string}
Returns the name of the registry that contains elements of this type
- Inherited From
- Type:
- string
remove()
Deletes the element and removes it from all containing registries and folders
- Inherited From
jsDocNoAdminRights
If deleting the element is not possible, e.g. when trying to delete a system element
setId(id, replaceScriptReferencesopt)
Registers the element with the given ID. If the element has already been registered, the current ID will be changed to the new ID.
Deprecated option: If the given ID is undefined or null, the element will be deregistered. Use deregister() instead
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
id | string | | The ID to set | ||
replaceScriptReferences | boolean | <optional> | false | True if ID references in scripts should be replaced. Only done when the old and the new ID is not undefined. |
- Inherited From
- See
- deregister
jsDocNoAdminRights
setName()
Sets the name of the element
- Since
- 6.1.1
- Inherited From
jsDocNoAdminRights
setSource(source)
Sets the source code of the script
| Name | Type | Description |
|---|---|---|
source | string | The new query source |
- Since
- 6.1.1
When no write transaction is active.
When this is a persistent script and the user does not have admin rights.
source() → {string}
Returns the script source code
- Since
- 5.4.2
If accessing the source is not allowed
- Type:
- string