Variables/Functions | Description | Examples |
---|
audit | To control the custom user audit function. The supported types are:
- count: Increments the string key value with 1
Code Block |
---|
| audit.count(key); |
- sum: Sums up the total amount
Code Block |
---|
| audit.sum(key,value); |
- set: Sets an input value. Data entry using the set function can be used with any data type. The output of the sum function will show the accumulated amount.
Code Block |
---|
| audit.set(key,value); |
|
Info |
---|
| audit.set ('Collection 1', JSON.stringify(object)): – This audit function can be used to enter any string value and save it to a specified key.
|
Info |
---|
| audit.sum ('KEY_NAME', payload.fieldName): - This function is useful when presenting amounts of data that is to be saved or forwarded to a destination source.
|
Info |
---|
| audit.count ('Tracking-Records-Changes'): - This function can be issued to increase the count of tracked records or a collection of data after an audit review.
|
|
log | An object that contains logging functionality for the severity levels: info, warning, and error. log.info("foo"); - Logs something to the log. See Logs.
Note |
---|
| - Large log messages are truncated, for example, messages that are greater than 100000 characters.
- The object takes one or more arguments and concatenates them to a single string.
- sprintf/printf placeholders are supported in the string for digits, json and strings.
- If you have more arguments than placeholders, the remaining arguments are concatenated at the end of the string in the order that they are provided.
|
Note |
---|
| Currently, the Console object in JavaScript, which provides access to the browser's debugging console, is disabled. |
|
Info |
---|
| log.info('This is %s object: %j, it contains %d greeting phrases',"my", { greeting: 'hello', message: 'world' }, 1);
This results in the message: "This is my object: {\"greeting\": \"hello\", \"message\": \"world\"}, it contains 1 greeting phrases".
|
|
| The payload variable contains all the information of the current record/object.
|
Info |
---|
| payload.foo = "bar"; - Sets the property foo in the payload to the string "bar" delete payload.foo; - Deletes the property foo from the payloadpayload.baz = { a: 1, b: 2, c: 2 }; - Sets the property baz in the payload to an object
|
|
| The meta variable provides generic information (metadata) about a payload (record). Metadata is data that provide information about other data. Metadata summarises basic information about data, thereby making finding and working with particular instances of data easier.
Refer to Amazon S3 to know about metadata that is accessible from the Transform tab :
The following metadata is accessible using the Script Flush tab: |
Info |
---|
title | Example using S3 Forwarder |
---|
| If you choose to add properties to meta , you can do so in the Script Function and refer it to a different function, for example, Amazon S3 forwarder. In the Script Function,
Code Block |
---|
| const moment = require("moment");
if (!meta.simDate)
{
meta.simDate = moment(new Date()).format('YYYYMMDD');
} |
In the Amazon S3 forwarder, add this in the Filename field: passages-${meta.simDate}.csv For more information, please see Configuring Dynamic Naming in Fields. |
|
push(<event>) | To send data downstream. You need to invoke this Function using await syntax.
| To send data to the next Function(s) in the stream.
|
| This is to keep the state across records. The state is only available during one stream execution. The information stored in the state variable is not persisted between executions and is cleared at the end of each stream execution. The state variable contains two scopes: - node: To save the state locally for this Function.
- stream: To save the state globally for the stream.
|
Info |
---|
| state.node - This state remains across one stream execution and is only available in this Function.
const foo = state.node.foo; - Retrieves the variable foo from Function
delete state.node.foo; - Removes the variable foo from Function
|
Info |
---|
| state.stream - This state is shared only within the Script Functions in a stream.
const foo = state.stream.foo; - Retrieves the variable foo from the stream
delete state.stream.foo; - Removes the variable foo from the stream
|
|
| These three operations functions as a key-value store. The key must be a string. Value can be of any type, for example: string, number, date, JSON object, and array.
You need to invoke this Function using await syntax: Note |
---|
| If a value exceeding the maximum limit is entered, the value is automatically set to the designed maximum. |
del: To delete a value Code Block |
---|
| await store.del(<key>) |
|
Info |
---|
| await store.get("foo") - Returns the value for the key "foo".
|
Info |
---|
| await store.set("foo", "hello"); - Sets the value for the key "foo" to the string "hello". The value is stored for 30 days, which is the default time for store.set.
|
Info |
---|
| await store.set("foo", "hello", {ttl:600000}); - Sets the value for the key "foo" to the string "hello". The ttl for this value is 600000 seconds.
|
|
| With shared persistent storage, streams can access the same data. For example, one stream writes data to the shared persistent storage that can be used by one or more streams. The key must be a string. Value can be of any type, for example, string, number, date, JSON object, and array. Note |
---|
| Streams sharing data must belong to the same solution. |
You must use the await syntax for the Function: sharedStore.get: To get a value.
Code Block |
---|
| await sharedStore.get("<key>"); |
sharedStore.set: To set a value of a key and the duration (in seconds) of how long the key is stored.
Code Block |
---|
| await sharedStore.set("<key>", <value>); |
And, to set the duration (in seconds) of how long the key is stored.
Code Block |
---|
| await sharedStore.set("<key>", <value>,{ttl:<storage duration in number of seconds>}); |
Note |
---|
| If a value exceeding the maximum limit is entered, the value is automatically set to the designed maximum. |
|
Info |
---|
| await sharedStore.get("foo") - Returns the value from the shared persistent storage for the key foo .
|
Info |
---|
| await sharedStore.set("Team", "hello"); - Sets the value for key "Team" to the string "hello". The ttl for this value is set to default, 2592000 seconds.
const getVal = await sharedStore.get("Team");
await sharedStore.del("Team");
|
Info |
---|
| await sharedStore.set("Team",{ foo: 42 }, {ttl: 6000}); - Sets the value for key "Team" to the object { foo: 42 }. The ttl for this value is 6000 seconds.
const getVal = await sharedStore.get("Team");
await sharedStore.del("Team");
|
|