Skip to content

Latest commit

ย 

History

History
1701 lines (1213 loc) ยท 30.7 KB

Oktopus Functions.md

File metadata and controls

1701 lines (1213 loc) ยท 30.7 KB

Documentation and examples for whoosh Oktopus functions

Version: 5.18.0 - 2024-10-15
Link: Documentation on GitHub

Language

whoosh Oktopus uses Scriban as scripting/templating engine.
Check out the

for further information.

Oktopus built-in functions

This document describes the built-in functions provided by whoosh Oktopus (in addition to Scriban built-in functions).

array functions

Array functions available through the object 'array' in whoosh Oktopus.

๐Ÿ”

array.isNullOrEmpty

array.isNullOrEmpty <list>

Description

Returns if an input list is null or empty. The shortcut array.empty can be used instead.

Arguments

  • list: The input list

Returns

true if list is empty; otherwise false

Examples

input

{{ array.isNullOrEmpty [] }}
{{ array.isNullOrEmpty [1, 2, 3]  }}

output

true
false

๐Ÿ”

array.hasItems

array.hasItems <list>

Description

Returns if an input list has elements.

Arguments

  • list: The input list

Returns

true if list has elements; otherwise false

Examples

input

{{ array.hasItems [1, 2, 3] }}
{{ array.hasItems [] }}

output

true
false

๐Ÿ”

array.remove

array.remove <list> <remove>

Description

Removes an element from an input list.

Arguments

  • list: The input list
  • remove: The element to remove from the list. Must be a scalar value

Returns

A new list with the element removed

Examples

input

{{ array.remove [1, 2, 3] 1 }}

output

[2, 3]

๐Ÿ”

convert functions

Convert functions available through the object 'convert' in whoosh Oktopus.

๐Ÿ”

convert.toCsv

convert.toCsv <value> <header>?

Description

Converts the input value to a CSV. An optional header can be passed to specify the CSV header. If the header is not specified then the return will have no CSV header.

Arguments

  • value: The input object
  • header: An optional string of comma-separated values that represent the CSV header

Returns

The input value converted to a CSV

Examples

input

{{ convert.toCsv {Id:1,Text:"Foo"} }}
{{ convert.toCsv {Id:1,Text:"Foo"} "Id,Text" }}
{{ convert.toCsv [{Id:1,Text:"Foo"},{Id:2,Text:"Bar"}] "Id,Text" }}

output

1,Foo
Id,Text
1,Foo
Id,Text
"{Id: 1, Text: ""Foo""}","{Id: 2, Text: ""Bar""}"

๐Ÿ”

convert.toCsvRows

convert.toCsvRows <value> <header>?

Description

Converts the input value to a CSV rows. An optional header can be passed to specify the CSV header. If the header is not specified then the return will have no CSV header.

Arguments

  • value: The input object
  • header: An optional string of comma-separated values that represent the CSV header

Returns

The input value converted to CSV rows

Examples

input

{{ convert.toCsvRows {Id:1,Text:"Foo"} }}
{{ convert.toCsvRows {Id:1,Text:"Foo"} "Id,Text" }}
{{ convert.toCsvRows [{Id:1,Text:"Foo"},{Id:2,Text:"Bar"}] "Id,Text" }}

output

1,Foo

Id,Text
1,Foo

Id,Text
1,Foo
2,Bar

๐Ÿ”

convert.toDecimal

convert.toDecimal <value> <culture>?

Description

Converts the input value to a 128 bit decimal. An optional culture can be passed to specify the format of the value. If the culture is not specified then the default will be used.

Arguments

  • value: The input object
  • culture: An optional string of the culture format

Returns

The input value converted to a 128 bit decimal

Examples

input

{{ convert.toDecimal "1.337,01" "de" }}
{{ convert.toDecimal "1,337.01" "en" }}

output

1337.01
1337.01

๐Ÿ”

convert.toDouble

convert.toDouble <value> <culture>?

Description

Converts the input value to a 64 bit double. An optional culture can be passed to specify the format of the value. If the culture is not specified then the default will be used.

Arguments

  • value: The input object
  • culture: An optional string of the culture format

Returns

The input value converted to a 64 bit double

Examples

input

{{ convert.toDouble "1,337" "de" }}
{{ convert.toDouble "1,337" "en" }}

output

1.337
1337

๐Ÿ”

convert.toInt

convert.toInt <value> <culture>?

Description

Converts the input value to a 32 bit integer. An optional culture can be passed to specify the format of the value. If the culture is not specified then the default will be used.

Arguments

  • value: The input object
  • culture: An optional string of the culture format

Returns

The input value converted to a 32 bit integer

Examples

input

{{ convert.toInt "1,337" }}
{{ convert.toInt "1337" }}

output

1337
1337

๐Ÿ”

convert.toLong

convert.toLong <value> <culture>?

Description

Converts the input value to a 64 bit integer. An optional culture can be passed to specify the format of the value. If the culture is not specified then the default will be used.

Arguments

  • value: The input object
  • culture: An optional string of the culture format

Returns

The input value converted to a 64 bit integer

Examples

input

{{ convert.toLong "1,337" }}
{{ convert.toLong "1337" }}

output

1337
1337

๐Ÿ”

convert.toText

convert.toText <value>

Description

Converts the input value to a string. The shortcut convert.toString can be used instead.

Arguments

  • value: The input object

Returns

The input value converted to a string

Examples

input

{{ convert.toText 1.337 }}
{{ convert.toText 1337 }}

output

"1.337"
1337

๐Ÿ”

dateOnly functions

DateOnly functions available through the object 'dateOnly' in whoosh Oktopus.

๐Ÿ”

dateOnly.from

dateOnly.from <dateTime>

Description

Returns the date string of an input dateTime.

Arguments

  • dateTime: The input datetime object

Returns

The date string of the dateTime input

Examples

input

{{ dateOnly.from date.now }}
{{ dateTime = date.parse "2024/12/31 13:37:00Z"; dateOnly.from dateTime  }}

output

2024-01-01
2024-12-31

๐Ÿ”

dateOnly.now

dateOnly.now

Description

Returns a date string of the current time.

Arguments

Returns

Examples

input

{{ dateOnly.now }}

output

2024-01-01

๐Ÿ”

dateOnly.parse

dateOnly.parse <dateString> <culture>?

Description

Returns a date string of an input date string. An optional culture can be passed to specify the format of the dateString. If the culture is not specified then the default will be used.

Arguments

  • dateString: The input date string
  • culture: An optional string of the culture format

Returns

A date string of the input dateString

Examples

input

{{ dateOnly.parse "2024-01-01" }}
{{ dateOnly.parse "2024/12/31" }}
{{ (dateOnly.parse "2024-12-31") | object.format "m" }}
{{ dateOnly.parse "31-12-2024" "de" }}

output

2024-01-01
2024-12-31
December 31
2024-12-31

๐Ÿ”

dateOnly.today

dateOnly.today

Description

Returns a date string of the current time.

Arguments

Returns

Examples

input

{{ dateOnly.today }}

output

2024-01-01

๐Ÿ”

globalVariable functions

Global variable functions available through the object 'globalVariable' in whoosh Oktopus.

๐Ÿ”

globalVariable.load

globalVariable.load <globalVariableName>

Description

Returns the value of a global variable. Global variables have to be set with a name and a value under Global variables

Arguments

  • globalVariableName: The name of the global variable

Returns

The value of the input globalVariableName

Examples

input

{{ globalVariable.load "MyGlobalVariable" }}

output

"MyValue"

๐Ÿ”

globalVariable.store

globalVariable.store <value> <globalVariableName>

Description

Stores a global variable of an input value. If the globalVariableName already exists then the new value will be stored, otherwise the new globalVariableName and the value will be added under Global variables. The shortcut globalVariable.set can be used instead.

Arguments

  • value: The input object
  • globalVariableName: The name of the global variable

Returns

Examples

input

{{ globalVariable.store "MyValue" "MyGlobalVariable" }}

output

Storing global variable 'MyGlobalVariable'='MyValue'

๐Ÿ”

html functions

HTML functions available through the object 'html' in whoosh Oktopus.

๐Ÿ”

html.removeAllAttributes

html.removeAllAttributes <htmlString>

Description

Removes all attributes of the input htmlString.

Arguments

  • htmlString: The input HTML string

Returns

A new HTML string with all attributes removed

Examples

input

{{ html.removeAllAttributes "<html><head></head><body><p src='FooBar'>FooBar</p></body></html>" }}

output

<html><head></head><body><p>FooBar</p></body></html>

๐Ÿ”

html.removeAttributes

html.removeAttributes <htmlString>

Description

Removes the attributes of the input htmlString. XML namespaces, src and href are not removed by this function, if you want to remove all attributes then use html.RemoveAllAttributes.

Arguments

  • htmlString: The input HTML string

Returns

A new HTML string with the attributes removed

Examples

input

{{ html.removeAttributes "<html><head></head><body><p title='FooBar'>FooBar</p></body></html>" }}

output

<html><head></head><body><p>FooBar</p></body></html>

๐Ÿ”

json functions

JSON functions available through the object 'json' in whoosh Oktopus.

๐Ÿ”

json.deserialize

json.deserialize <jsonString>

Description

Deserializes the input jsonString. The shortcut json.parse can be used instead.

Arguments

  • jsonString: The input JSON string

Returns

A new JSON object

Examples

input

{{ json.deserialize '{"Foo":"Bar"}' }}

output

{Foo: "Bar"}

๐Ÿ”

json.format

json.format <jsonString>

Description

Indents the input jsonString.

Arguments

  • jsonString: The input JSON string

Returns

A new formatted JSON string

Examples

input

{{ json.format '{"Foo":"Bar"}' }}

output

{
 "Foo":"Bar"
}

๐Ÿ”

json.serialize

json.serialize <json> <options>?

Description

Serializes the input json. If options is set to "Indented" then the resulting JSON string will be intended.

Arguments

  • json: The input JSON object
  • options: An optional string that can be set to "Indented"

Returns

A new JSON string

Examples

input

{{ json.serialize {Foo:"Bar"} }}
{{ json.serialize {Foo:"Bar"} "Indented" }}

output

{"Foo":"Bar"}

{
 "Foo":"Bar"
}

๐Ÿ”

oktopus functions

Oktopus information functions available through the object 'oktopus' in whoosh Oktopus.

๐Ÿ”

oktopus.server

oktopus.server

Description

Returns a JSON of relevant information of the current whoosh Oktopus instance.

Arguments

Returns

Examples

input

{{ oktopus.server }}
{{ oktopus.server.uptime | object.format "%d" }}

output

{"MachineName":"TESTDEV","Uptime":"1.33:07:00.1337000","Version":"5.9.0","EnvironmentName":"Test Environment"}'
1

๐Ÿ”

step functions

Oktopus step functions available through the object 'step' in whoosh Oktopus. These functions can be set to control the workflow to enable branching in steps or enable advanced error handling.

๐Ÿ”

step.errorMessage

step.errorMessage

Description

Returns the error message of when a step fails. This is typically used under Advanced Settings in the Error handling script.

Arguments

Returns

Examples

input

if (step.errorMessage | string.contains "temporarily unavailable") step.retryIn (timespan.from_seconds 5) end

output

<input>(1,1): Waiting for 5000ms...
Error handling script decided to retry step [...]

๐Ÿ”

step.item

step.item

Description

Returns the item set in the current step context. This can be used in certain steps like Create or update Business Object(s) in the Ivanti Service Manager technology by using an item, like a JSON, in the Items (mass upsert) field. In other fields set in the current step you can iterate over the item by using step.item and a key that is set in the item.

Arguments

Returns

Examples

input

{{ step.item.id }}
{{ step.item.name | convert.toCsv }}

output

๐Ÿ”

step.retry

step.retry

Description

Retries a step if it fails. This is typically used under Advanced Settings in the Error handling script.

Arguments

Returns

Examples

input

{{ step.retry }}

output

Error handling script decided to retry step [...]

๐Ÿ”

step.retryIn

step.retryIn <timespan>

Description

Waits for a given timespan ( set in milliseconds ) and then retries a step if it fails . This is typically used under Advanced Settings in the Error handling script.

Arguments

  • timespan: The input timespan object

Returns

Examples

input

{{ step.retryIn (timespan.from_seconds 5) }}

output

<input>(1,1): Waiting for 5000ms...
Error handling script decided to retry step [...]

๐Ÿ”

step.skip

step.skip

Description

Skips the current step. This is typically used under Advanced Settings in the Error handling script.

Arguments

Returns

Examples

input

{{ step.skip }}

output

Skipping step [...]

๐Ÿ”

step.skipIf

step.skipIf <value>

Description

Skips the current step if the input value evaluates to true.

Arguments

  • value: The input object

Returns

Examples

input

{{ step.skipIf true }}
{{ step.skipIf false }}

output

Skipping step [...]
Successfully executed step [...]

๐Ÿ”

step.skipIfEmpty

step.skipIfEmpty <value>

Description

Skips the current step if the input value is null or is an empty string.

Arguments

  • value: The input object

Returns

Examples

input

{{ step.skipIfEmpty null }}
{{ step.skipIfEmpty "" }}
{{ step.skipIfEmpty {} }}

output

Skipping step [...]
Skipping step [...]
Successfully executed step [...]

๐Ÿ”

step.skipIfNull

step.skipIfNull <value>

Description

Skips the current step if the input value is null.

Arguments

  • value: The input object

Returns

Examples

input

{{ step.skipIfNull null }}
{{ step.skipIfNull {} }}

output

Skipping step [...]
Successfully executed step [...]

๐Ÿ”

step.wait

step.wait <timespan>

Description

Waits for a given timespan ( set in milliseconds ). This is typically used under Advanced Settings in the Error handling script.

Arguments

  • timespan: The input timespan object

Returns

Examples

input

{{ step.wait (timespan.from_seconds 5) }}
{{ step.wait 5) }}

output

<input>(1,1): Waiting for 5000ms...
<input>(1,1): Waiting for 5ms...

๐Ÿ”

string functions

String functions available through the object 'step' in whoosh Oktopus.

๐Ÿ”

string.getFileName

string.getFileName <name> <extension> <fallbackName>?

Description

Returns the file name of of the input name and extension. The optional fallbackName will be used if name contains invalid characters, like '/', '', '<', '>', '|', ':', '*', '?' or '"'.

Arguments

  • name: The input string of the resulting file name
  • extension: The input string of the resulting file name extension
  • fallbackName: An optional string that is used instead of name

Returns

A new string of file name

Examples

input

string.GetFileName "Test" "eml" "Email"
string.GetFileName "<>" "eml" "Email"

output

Test.eml
Email.eml

๐Ÿ”

string.hasContent

string.hasContent <value>

Description

Returns if an input value has content.

Arguments

  • value: The input string

Returns

true if value has content; otherwise false

Examples

input

{{ string.hasContent "Test" }}
{{ string.hasContent "" }}

output

true
false

string.isNullOrEmpty

string.isNullOrEmpty <value>

Description

Returns if an input value is null or empty.

Arguments

  • value: The input string

Returns

true if value is empty; otherwise false

Examples

input

{{ string.isNullOrEmpty "" }}
{{ string.isNullOrEmpty "Test" }}

output

true
false

๐Ÿ”

timeOnly functions

TimeOnly functions available through the object 'timeOnly' in whoosh Oktopus.

๐Ÿ”

timeOnly.from

timeOnly.from <dateTime>

Description

Returns a time object of an input dateTime.

Arguments

  • dateTime: The input datetime object

Returns

A new time object of the dateTime input.

Examples

input

{{ timeOnly.from date.now }}
{{ dateTime = date.parse "2024/12/31 13:37:00Z"; timeOnly.from dateTime  }}

output

13:37:00.0000000
14:37:00.0000000

๐Ÿ”

timeOnly.now

timeOnly.now

Description

Returns a new time object of the current time.

Arguments

Returns

Examples

input

{{ timeOnly.now }}

output

13:37:00.0000000

๐Ÿ”

timeOnly.parse

timeOnly.parse <timeString> <culture>?

Description

Returns a time object of an input time string. An optional culture can be passed to specify the format of the timeString. If the culture is not specified then the default will be used.

Arguments

  • timeString: The input time string
  • culture: An optional string of the culture format

Returns

A new time object of the input dateString

Examples

input

{{ timeOnly.parse "13:37:00" }}
{{ (timeOnly.parse "13:37:00") | object.format "HH" }}
{{ timeOnly.parse "1:37 PM" }}

output

13:37:00.0000000
13
13:37:00.0000000

๐Ÿ”

variable functions

Variable functions available through the object 'variable' in whoosh Oktopus.

๐Ÿ”

variable.skip

variable.skip

Description

Skips the variable of a step.

Arguments

Returns

Examples

input

{{ variable.skip }}

output

Ignoring [...]

๐Ÿ”

variable.skipIf

variable.skipIf <value>

Description

Skips the variable of a step if the input value evaluates to true.

Arguments

  • value: The input object

Returns

Examples

input

{{ variable.skipIf true }}
{{ variable.skipIf false }}

output

Ignoring [...]
Successfully executed step [...]

๐Ÿ”

variable.skipIfEmpty

variable.skipIfEmpty <value>

Description

Skips the variable of a step if the input value is null or is an empty string. The shortcut variable.skipEmpty can be used instead.

Arguments

  • value: The input object

Returns

Examples

input

{{ variable.skipIfEmpty null }}
{{ variable.skipIfEmpty "" }}
{{ variable.skipIfEmpty {} }}

output

Ignoring [...]
Ignoring [...]
Successfully executed step [...]

๐Ÿ”

variable.skipIfNotEmpty

variable.skipIfNotEmpty <value>

Description

Skips the variable of a step if the input value is not an empty string. The shortcut variable.skipNotEmpty can be used instead.

Arguments

  • value: The input object

Returns

Examples

input

{{ variable.skipIfNotEmpty null }}
{{ variable.skipIfNotEmpty "" }}
{{ variable.skipIfNotEmpty "{}" }}

output

Successfully executed step [...]
Successfully executed step [...]
Ignoring [...]

๐Ÿ”

variable.skipIfNotNull

variable.skipIfNotNull <value>

Description

Skips the variable of a step if the input value is not null. The shortcut variable.skipNotNull can be used instead.

Arguments

  • value: The input object

Returns

Examples

input

{{ variable.skipIfNotNull {} }}
{{ variable.skipIfNotNull null }}

output

Ignoring [...]
Successfully executed step [...]

๐Ÿ”

variable.skipIfNull

variable.skipIfNull <value>

Description

Skips the variable of a step if the input value is null. The shortcut variable.skipNull can be used instead.

Arguments

  • value: The input object

Returns

Examples

input

{{ variable.skipIfNull null }}
{{ variable.skipIfNull {} }}

output

Ignoring [...]
Successfully executed step [...]

๐Ÿ”

variable.store

variable.store <value> <variableName>

Description

Stores the input value with a variableName in the current workflow context. To use the variable just call the variableName in any step after the variable was stored.

Arguments

  • value: The input object
  • variableName: The string for the variable name

Returns

Examples

input

{{ variable.store "Bar" "Foo" }}
{{ variable.store {Foo:"Bar"} "FooBar" }}

output

Storing variable 'Foo'='Bar'
Storing variable 'FooBar'='{"Foo":"Bar"}'

๐Ÿ”

variable.useNull

variable.useNull

Description

Forces null to be used as a variable instead of an empty string.

Arguments

Returns

Examples

input

{{ variable.useNull }}

output

Text = <null>

๐Ÿ”

workflow functions

Workflow functions available through the object 'workflow' in whoosh Oktopus.

๐Ÿ”

workflow.hideSecret

workflow.hideSecret <value>

Description

Prevent logging the clear text of the value.

Arguments

Returns

Examples

input

{{ workflow.hideSecret user.password }}

output

๐Ÿ”

workflow.log

workflow.log <value> <logLevel>?

Description

Logs the value under "Protocol" after the step was executed where the function was called. An optional logLevel string ( "[Success | Warning | Error]" ) can be used for advanced logging.

Arguments

Returns

Examples

input

{{ workflow.log "FooBar" }}
{{ workflow.log "FooBar" "Success" }}

output

๐Ÿ›ˆFooBar
โœ…FooBar

๐Ÿ”

workflow.stop

workflow.stop <message>?

Description

Stops the current workflow. An optional message string can be used to display a reason why the workflow stopped.

Arguments

  • message: An optional message string

Returns

Examples

input

{{ workflow.stop }}
{{ if MyVariable == "Abort" workflow.stop "Stopping workflow now." end }}

output

Stopping workflow at step [...]
Stopping workflow at step [...] "Stopping workflow now."

๐Ÿ”

workflow.stopIf

workflow.stopIf <value> <message>?

Description

Stops the current workflow if the input value evaluates to true. An optional message string can be used to display a reason why the workflow stopped.

Arguments

  • value: The input object
  • message: An optional message string

Returns

Examples

input

{{ workflow.stopIf true }}
{{ workflow.stopIf MyVariable == "Abort" "Stopping workflow now." }}
{{ workflow.stopIf false }}

output

Stopping workflow at step [...]
Stopping workflow at step [...] "Stopping workflow now."
Successfully executed step [...]

๐Ÿ”

workflow.stopIfEmpty

workflow.stopIfEmpty <value> <message>?

Description

Stops the workflow if the input value is null or is an empty string. An optional message string can be used to display a reason why the workflow stopped.

Arguments

  • value: The input object
  • message: An optional message string

Returns

Examples

input

{{ workflow.stopIfEmpty null }}
{{ workflow.stopIfEmpty "" "Stopping workflow now." }}
{{ workflow.stopIfEmpty {} }}

output

Stopping workflow at step [...]
Stopping workflow at step [...] "Stopping workflow now."
Successfully executed step [...]

๐Ÿ”

workflow.stopIfNull

workflow.stopIfNull <value> <message>?

Description

Stops the current workflow if the input value is null. An optional message string can be used to display a reason why the workflow stopped.

Arguments

  • value: The input object
  • message: An optional message string

Returns

Examples

input

{{ workflow.stopIfNull null }}
{{ workflow.stopIfNull null "Stopping workflow now." }}
{{ workflow.stopIfNull {} }}

output

Stopping workflow at step [...]
Stopping workflow at step [...] "Stopping workflow now."
Successfully executed step [...]

๐Ÿ”