ScriptableDataStream - Scoped, Global
-
- UpdatedJan 30, 2025
- 5 minutes to read
- Yokohama
- API reference
The ScriptableDataStream API provides methods to interact with a stream of data.
This class can only be used in a server-side script after retrieving a ScriptableDataStream object using one of these APIs:
- The executeDataStreamAction() method in the FlowAPI class. See FlowAPI.
- The getDataStream() method in the ScriptableFlowRunnerResult class. See ScriptableFlowRunnerResult.
After retrieving a ScriptableDataStream object, call the methods in this specific order:
- Use the hasNext() method to determine whether there are more items in the data stream.
- Use the next() method to access the next item in the stream.
- Use the getItemIndex(), getItemInPageIndex(), and getPageIndex() methods to get information from the stream.
- Use the close() method to close the stream.
This class runs is in the sn_fd
namespace.
try/catch
block to catch errors. Always include a
finally
statement that ends with the close()
method from the ScriptableDataStream class to close the data
stream and prevent performance issues.ScriptableDataStream - close()
Closes the connection to a data stream. Always call this method after performing any desired operations on a data stream.
You can only call this method on a ScriptableDataStream object returned from the executeDataStreamAction() method in the FlowAPI class. See FlowAPI.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
void |
Example
ScriptableDataStream - getItemIndex()
Returns the current index of an item in a data stream.
You can only call this method on a ScriptableDataStream object returned from the executeDataStreamAction() method in the FlowAPI class. See FlowAPI.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | Current index of an item in a data stream using zero-based indexing. |
Example
ScriptableDataStream - getItemInPageIndex()
Returns the current index of an item within the current page in a data stream.
You can only call this method on a ScriptableDataStream object returned from the executeDataStreamAction() method in the FlowAPI class. See FlowAPI.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | Current index of an item within the current page in the data stream using zero-based indexing. |
Example
ScriptableDataStream - getPageIndex()
Returns the current index of a page in a data stream.
You can only call this method on a ScriptableDataStream object returned from the executeDataStreamAction() method in the FlowAPI class. See FlowAPI.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | Current index of a page in a data stream using zero-based indexing. |
Example
ScriptableDataStream - hasNext()
Returns true if there are more items in the data stream.
You can only call this method on a ScriptableDataStream object returned from the executeDataStreamAction() method in the FlowAPI class. See FlowAPI.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Boolean | Flag that determines whether there are more items in the data stream. Values
include:
|
Example
This example creates an incident record for each item returned in the data stream.
ScriptableDataStream - next()
Returns the next item in a data stream.
You can only call this method on a ScriptableDataStream object returned from the executeDataStreamAction() method in the FlowAPI class. See FlowAPI.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Object | The next item in the data stream. This object contains the outputs defined by the Data Stream action. To view the Data Stream action outputs, navigate to the Outputs section of the Data Stream action in the Flow Designer interface. |
Example
This example creates an incident record for each item returned in the data stream.