Appearance
Javascript Expressions
The following JavaScript expressions are supported:
Variables
Workflow Variables
To set a workflow variable, use the setVariable function.
setVariable('CurrentOrderNr','255');
To access a workflow variable, use the getVariable function.
const currentOrderNr = getVariable('CurrentOrderNr');
`Current Order Nr ${currentOrderNr}`
Activity Output
Any activity might provide some output, which is accessible from any other activity using workflow expressions. To access an activity's output property called e.g. Output
using a JavaScript expression, you can do so by specifying activities
, then the activity name followed by .Output()
. Notice that you must invoke the property as if it were a method. This is due to the way workflow storage providers work, which are potentially asynchronous in nature (such as Azure Blob Storage).
For example, if you have an activity named MyActivity
, you can access its output as follows: activities.MyActivity.Output()
.
If the output is an object, you can access its properties too. For instance, the HTTP Endpoint activity returns the HTTP request as its output which is of type HttpRequestModel. When you name this activity "MyHttpEndpoint"
, you can access the HTTP request body like this:
activities.MyHttpEndpoint.Output().Body
If you happened to post a JSON document to your HTTP endpoint that looks like this:
{
"SomeDocument": {
"Title": "About Workflows"
}
}
Then you can access the "Title"
field like this:
activities.MyHttpEndpoint.Output().Body.SomeDocument.Title
If your activity is a direct child of an HTTP Endpoint activity, you can access its output directly via the
input
variable, which will be an instance ofHttpRequestModel
.
SendHttpRequest Activity
The SendHttpRequest activity has two output properties:
[ActivityOutput] public HttpResponseModel? Response { get; set; }
[ActivityOutput] public object? ResponseContent { get; set;
To access a SendHttpRequest activity with name SampleRequest1
's response content, use activities.SampleRequest1.ResponseContent()
.
input
Contains the input value that was received as output from the previously executed activity, if any.
input: object?
workflowInstanceId
Contains the workflow instance ID of the currently executing workflow.
workflowInstanceId: string
workflowDefinitionId
Contains the workflow definition ID of the currently executing workflow.
workflowDefinitionId: string
workflowDefinitionVersion
Contains the workflow definition version of the currently executing workflow.
workflowDefinitionVersion: number
correlationId
Contains the correlation ID of the currently executing workflow.
correlationId: string?
currentCulture
Contains the current culture.
currentCulture: CultureInfo
workflowContext
Contains the workflow context (if any) of the currently executing workflow.
workflowContext: object?
currentCulture
Returns the current culture.
currentCulture: CultureInfo
Common Functions
guid
Generates a new GUID value and returns its string representation.
guid(): string
parseGuid
Parses a string into a GUID value.
parseGuid(value: string): Guid
setVariable
Sets a workflow variable to the specified value.
setVariable(name: string, value: object): void
getVariable
Returns a workflow variable with the specified name.
getVariable(name: string): object
getTransientVariable
Returns a transient workflow variable with the specified name.
getTransientVariable(name: string): object
isNullOrWhiteSpace
Returns true
if the specified string is null, empty or consists of white space only, false
otherwise.
isNullOrWhiteSpace(value: string): boolean
isNullOrEmpty
Returns true
if the specified string is null or empty, false
otherwise.
isNullOrEmpty(value: string): boolean
isEmpty
Returns true
if the specified object is null or empty, false
otherwise.
isEmpty(src: any): bool
objectMapper
Copies properties from one Object
to another based on instructions given in a map Object
, which defines which properties should be mapped.
objectMapper(src: any,map:any): any
var map = {
"foo": [
{
key: "foo",
transform: function (value) {
return value + "_foo";
}
},
{
key: "baz",
transform: function (value) {
return value + "_baz";
}
}
],
"bar": "bar"
};
var src = {
foo: 'blah',
bar: 'something'
};
var dest = objectMapper(src, map);
// dest.foo: 'blah_foo'
// dest.baz: 'blah_baz'
// dest.bar: 'something'
merchantApiUrl
Converts the specified relative path into a fully-qualified absolute URL with Merchant:Api:BaseUrl
in appsettings.json
.
merchantApiUrl(url: string): string
"Merchant": {
"Api": {
"BaseUrl": "http://localhost:47690"
}
}
setCacheVariable
Sets a cache variable to the specified value.
setCacheVariable(name: string, value?: any): void
getCacheVariable
Returns a cache variable with the specified name.
getCacheVariable(name: string): any
Workflow Functions
getWorkflowDefinitionIdByName
Returns the ID of the specified workflow by name. This is useful when for instance you are using the RunWorkflow
activity, which requires the ID of the workflow definition to run.
getWorkflowDefinitionIdByName(name: string): string?
getWorkflowDefinitionIdByTag
Returns the ID of the specified workflow by tag. This is useful when for instance you are using the RunWorkflow
activity, which requires the ID of the workflow definition to run.
getWorkflowDefinitionIdByTag(tag: string): string?
HTTP Functions
queryString
Returns the value of the specified query string parameter.
queryString(name: string): string
absoluteUrl
Converts the specified relative path into a fully-qualified absolute URL.
absoluteUrl(path: string): string
signalUrl
Generates a fully-qualified absolute signal URL that will trigger the workflow instance from which this function is invoked.
signalUrl(signal: string): string
Date/Time Functions
instantFromDateTimeUtc
Returns a new Instant
object from the specified DateTime
value.
Make sure that the DateTime value's Kind property is DateTimeKind.Utc.
currentInstant
Returns the current date/time value in the form of a NodaTime's Instant
object.
currentInstant(): Instant
currentYear
Returns the current year.
currentYear(): number
startOfMonth
Returns the start of the month of the specified instant
. If no instant
is specified, the current instant is used.
startOfMonth(instant: Instant?): LocalDate;
endOfMonth(instant: Instant?)
Returns the end of the month of the specified instant
. If no instant
is specified, the current instant is used.
endOfMonth(instant: Instant?): LocalDate;
startOfPreviousMonth
Returns the start of the previous month of the specified instant
. If no instant
is specified, the current instant is used.
startOfPreviousMonth(instant: Instant?): LocalDate;
plus
Adds the specified Duration
to the specified Instant
and returns the result.
plus(instant: Instant, duration: Duration): Instant
minus
Subtracts the specified Duration
from the specified Instant
and returns the result.
minus(instant: Instant, duration: Duration): Instant
durationFromDays
Returns a duration constructed from the specified number of days.
durationFromDays(days: number): Duration
formatInstant
Formats the specified Instant
using the specified format string
and CultureInfo
. If no culture info is provided, CultureInfo.InvariantCulture
is used.
formatInstant(instant: Instant, format: string, cultureInfo: CultureInfo?): string
localDateFromInstant
Returns the LocalDate
portion of the specified Instant
.
localDateFromInstant(instant: Instant): LocalDate
instantFromLocalDate
Creates an Instant
from the specified LocalDate
value (start of date).
instantFromLocalDate(localDate: LocalDate): Instant