Split Use Examples
Basic Expression Split
In this example we will split a list of company branches that are provided in the “TestExpression”. This list is comma separated. The default separator used by the split service is also a comma.
We can see above that the seven branches mentioned in the “TestExpression” are fed into the Expression input and keeping ‘,’ as the separator we get a set of seven Branch outputs one after the other.
In order to logically use the output of the split function, the most common thing to do is to run a for-each loop over the split service. This way a process loop is created such that every time in the loop there is one item from the list which has been singled out by the Split. Here is how that looks and is created:
Splitting Process Input
In this example, we have an “Add To Cart” process which accepts as input the data on the items to be added to the cart. This means the process should have a format which allows for multiple items to be sent. One way to do this is to pass comma separated lists for each property belonging to an item and then send each of the inputs through a split service.
Here is the process canvas. Early on in the process, the input is split and then the results are looped on with a for each loop later.
Splitting Web Fields
In this example we have a table which has user input textboxes. The table has three columns. The product code, a column which denotes if order is placed or not and a user input for the product cost. Our objective here is to split these rows and the user input so that we can return a total sum of all the the products that have been ordered.
One thing to keep in mind is that web fields in EasyProcess use a special separator. The value of the separator is stored in the default AppSettings under the variable name ‘EP_Separator’. Usually we set its value to ‘#EP#’ instead of something like a comma. This comes in handy when the web fields that need to be separated themselves contain commas. Consider a table column that stores formatted dollar price values like $25,000. Such items would be correctly separated by an arbitrary ‘#EP#’ separator. It is highly unlikely that we or a client would use #EP# in the data, so this works best.
Here we are splitting both the “OrderPlaced” flag and the “ProductCost” textboxes at the same time. This way within every split we get the corresponding values paired up together row by row.
Now we set up a For-Each loop that will iterate through the results of the Split service. Before the For-Each loop begins, we set a variable “Sum” as 0. This will be our running count which will grow as we continue the loop.
Inside the Split’s for-each loop, we can first check if the “OrderPlaced” flag is true. When it is equal to “True”, we add its value to the running sum with the “Sum” Evaluate service. Finally when the loop is finished, we have our final total in the “Sum” Evaluate service.
In the SetFieldProperties, we set the “Grand Total” text box with the sum variable by referencing the “Sum” evaluate.