---
title: Understanding Expression Evaluation and Functions
slug: understanding-expression-evaluation-and-functions
createdAt: 2025-06-11T20:26:19.223Z
---

Activate expressions start with an "=" sign. These expressions can be evaluated at different times depending upon the context that they are being used.

- The general rule is that expressions are evaluated only when the value is needed.
- Expressions can be wrapped in quotes " to stop the parser interpreting special characters
  - For example =eval(=//Roles/My-NewRole) would actually be intepreted as =eval( \[=//Roles/My]  MINUS \[NewRole] ) which is not the desired result however =eval("=//Roles/My-NewRole") would work as expected.
- Expressions passed to a function are evaluated at that point and the result is passed to the function.

For example, consider the following example

\<groups>
  \<group>=//Resources/Groups/group1\</group>
  \<group>=//Resources/Groups/group2\</group>
  \<group>=//Resources/Groups/group3\</group>
\</groups>

If you wanted to use a foreach statement to display a list of the names you could write the following:-

1\. =foreach(=/groups/group, "=/name")

2\. =foreach(=/groups/group, =/name)

3\. =foreach(=/groups/group, "%=/name%")

However, only one example is correct - number 3.  

## Explanation

All expressions starting with = or strings starting with "=XXXX" are evaluated and passed to the function.

1\. =foreach(=/groups/group, "=/name")
    The first argument will return the list of groups and the second argument will be evaluated immediately and return the 'name' of the current context - probably the job or "";

    Arguments passed to the function: =foreach(XmlList:\{group1,group2,group3}, String:””)
    Result: ""   - each group is looped over an an empty string is added to the result.

2\. =foreach(=/groups/group, =/name)

This is exactly the same as the previous example

3\. =foreach(=/groups/group, "%=/name%")

    The %= stops the expression being evaluated by the parser and passes it to the function as is.

    Therefore, what gets passed to the function is

```text
    =foreach(XmlList:{group1,group2,group3}, String:”%=/name% ”) 
```

    Now evaluating the %=/Name% for each item in the list will give the expected result.

    Result: group1 group2 group3
