LibraryEASYProcess Reference Manual 5ProcessesServicesProcessFlowWorkshopSelectNode

SelectNode Overview

SelectNode allows you to keep only a subset of a given Node (Ex: “WorkData/Inquire”). This subset is taken by specifying the index of the first and last record in the range you would like to keep. If a previous node in the logs has x results, SelectNode changes the logs so that only the range from StartIndex to EndIndex appears in the logs.

For instance, if we have a query that has 5 results, followed by a SelectNode with a StartIndex of 1 and EndIndex of 3, the end result will have only 3 results. It also will only have the first 3. Of the original results, imagine they are indexed starting at 1. In order to select the top three records you would use a StartIndex of 1 and EndIndex of 3. If you want the bottom 3 results, you would use a StartIndex of 3 and an EndIndex of 5.

There is another service called SelectNodes which also allows you to take a subset of the given Node, but the subset is specified using an XSLT predicate (square brackets used to filter).

SelectNode Use Examples
NodeThis is the node of which we will be selecting a subset.

StartIndexIf each result of the Node were indexed starting at 1, this StartIndex would indicate the first result in the selected range to show.

EndIndexIf each result of the Node were indexed starting at 1, this EndIndex would indicate the last result in the selected range to show.

SelectNode Use Examples

Basic Use Example

In this example, we have a Node followed by a SelectNode. If we run in step so that the SelectNode does not have a chance to run yet, the Node output has 5 results.

If we look at the SelectNode configuration, we can see the StartIndex is set to 1 and the EndIndex is set to 3. Since I gave each of our nodes a visible index, after SelectNode runs, we will be able to expand the node and see which indexes were selected and which were dropped from the logs.

In the logs below we can see only 3 Node results are present. If we expand them, the nodes left have an index value of 1, 2, and 3.

SelectNode successfully selected a subset of the given Node and altered the logs to only display the range given by the StartIndex and EndIndex. Here is how the SelectNode logs appear:

Using 0 for StartIndex

The SelectNode service starts the indexing of the Node at 1. So, when you give it a StartIndex of 0, it still has the same behavior as if it were given a StartIndex of 1.

Used in a REST API for Paging of Results

In this example, SelectNode was usedin a GetOrderDetails REST API. The REST request would send an input of the StartIndex and EndIndex. This way the request could specify “I want only the first 10 results”. This is because the page would only show 10 at a time. Then as the user wanted to scroll through other pages, the API could be called again with a StartIndex of 11 and EndIndex of 20. Here is the process canvas for this API and the input in EASYProcess vs the JSON request used to call the API.

First we are going to call the API without sending a FromRecord or ToRecord. The default behavior it to select 1 and 999 when no values are passed in so that the results are not limited. Here is that logs in the SelectNode service:

In the logs, we can see that this order has 4 records returned from GetOrderDetails.

Next we are going to call the API with a ToRecord of 2 and a FromRecord of 1. After looking at the logs, we can see the same order has its GetOrderDetails results limited to 2:

Using SelectNode to Clear Output

Sometimes when dealing with loops, you will want to clear the previous output of a query so that it does not interfere with your next loop iteration. Lets say you are going to loop multiple times. During the loop, you don’t want a service of the same name to override the existing output. You want them to stack so that at the end of the loop you can look back at all of the nodes with that name and use it. However, after this loop iteration, you want a fresh start.

This can be done with SelectNode. Simply set the StartIndex and EndIndex to 0. This will select an empty subset of the Node and clear it from the logs.

Powered by EASYProcess (© 2022 K-Rise Systems, Inc).