Evaluate Use Examples
Evaluate Basic Use
In this example we have a field for Name in [LastName], [FirstName] format. In the “Test Evaluate” button process we have an Evaluate service named “GetName”. Within “GetName”, we are using xslt substring functions to retrieve the FirstName and LastName values. We accomplish this by parsing the user-entered input string for FullName.
Here’s a closer look at the Evaluate service configuration:
Notice that we’re using XSLT functions substring-after and substring-before to get first and last names respectively. In this way we can use first name and last name later in the process without having to use substring functions again.
Here’s how the output logs for the Evaluate “GetName” service:
Storing a Variable for a Process
In this example, we use the Evaluate service to store the Shopping Cart’s “View Type” variable in a process and then reference this variable later in the same process.
This is useful when there are multiple branches of a process that will retrieve a variable different ways. The rest of the process will use the variable exactly the same, so in order to cut down on duplicate logic, we have each branch of the process define the variable in their own way.
Here we can see the process canvas:
In this process we want to retrieve the Shopping Cart’s View Type value. This can be either “Content” or “Grid”. Here are all the following cases we can encounter:
- The user has previously selected a view type which was saved to a cookie. We retrieve this value from the cookie and will load the page in the user selected view type.
- The user has not previously selected a view type for the shopping cart. We will load the page in its default view (which we save in a Configuration Variable).
In both branches of the button process, an Evaluate service named “CartViewType” is used to store the variable in an Eval named “View”. This creates a “CartViewType/View” variable (whose value can be either “Content” or “Gridview”) within the WorkData of the process that we can reference later.
Here are the two Evaluate service configurations:
Notice that we’ve named both the evaluates as “CartViewType” and the evaluate node as “View”. This way we can use “WorkData/CartViewType/View” in “BinaryDecision” service without worrying about which Evaluate runs. See below the Binary Decision:
The result of the binary decisions determine which visibility of areas on the page.