The advanced view allows you to create more elaborate rules for Smart Groups or Smart Locations, with ‘and’/‘or’ logical operators, nested operations and additional date formatting functions. The advanced view uses a text editor to create code-like queries.
General syntax
A single rule looks like this:
user.firstname.is(“John”) where:
- user is an object you refer to
- firstname is it’s property (a placeholder for user profile fields)
- “is" is operator you want to apply to the property
- (“John”) is a list of values you want to check object property against
So, the general syntax rule is object.property.operator(values).
For date profile fields we also support formatting. Syntax will look like
object.property.format(format).operator(values).
Details of date formatting are described below.
Syntax for dropdown profile fields
Smart Groups and Locations also support drop-down profile fields. In the example below, we use “Visual Editor” to select one of the possible values for the Function drop-down profile field.
When we switch to Advanced view, you see that the select option was translated to a number. In this example “13”.
The numbers assigned to drop-down profile field options represent the line number in which they were created. This number does not change if the order of the options is changed. You can review the current order of drop-down profile fields by navigating to Settings/Profile fields and editing the desired field.
Keep in mind that option numbers need to be provided as text in double quotes.
Syntax for date profile fields
Advanced view also supports distinct operations for date profile-fields like “on or before”, “on or after”, “between” and date formatting.
To show the difference between different operations we’ll consider examples with use of the hire_date profile field. Let’s assume this field contains information about when an employee was hired.
Keep in mind that when using the advanced view, dates are displayed in the YYYY-MM-DD format. In this format, YYYY represents the year, MM represents the month, and DD represents the day. Both MM and DD will include a leading 0 when necessary. For instance, January 7, 2025, would be written as "2025-01-07".
Is/Is not
The is/is not function checks if the value of a date profile field matches the arguments provided. For instance, user.hire_date.is("2025-03-31", "2024-12-01") will include users whose hire date is precisely March 31, 2025, or December 1, 2024. In contrast, isNot will exclude users hired on those specific dates.
On or before
The syntax user.hire_date.onOrBefore("2025-03-31") can be used to capture all users whose hire date value falls before or on a specific date. In this example, "hire_date" refers to the date profile field, "onOrBefore" is the operation, and "2025-03-31" is the date argument. This specific function will capture all users hired on or before March 31, 2025.
On or After
The syntax user.hire_date.onOrAfter("2025-03-31") can be used to capture all users whose hire date value falls after or on a specific date. In this example, "hire_date" refers to the date profile field, "onOrAfter" is the operation, and "2025-03-31" is the date argument. This specific function will capture all users hired on or after March 31, 2025.
Between
The syntax "user.hire_date.between("2025-03-01","2025-03-31")" can be used to find all users whose date profile field value falls within a specified date range. In this example, it will capture all users whose hire date is on or after March 1, 2025, and on or before March 31, 2025. This function will effectively find all users hired in March 2025.
Date formatting
The advanced view allows for flexible date formatting, which is particularly useful when you only need to use one of the date field components. For example, the syntax user.hire_date.format("yyyy-MM").between("2025-01", "2025-03")
- format("yyyy-MM") specifies the format for the hire_date profile field
- between("2025-01", "2025-03") is a function that takes 2 arguments that must be provided in the same format as in format("yyyy-MM")
This rule will return all users who were hired between January and March 2025, regardless of the specific day of hire.
The following formats are available for each date profile field:
- yyyy-MM-dd: The full date including year, month, and day, with leading zeros.
- yyyy: The year.
- yyyy-MM: The year and month.
- yyyy-ww: The year and week number.
- ww: The week number for a given date, with a leading 0.
- MM: The month number, with a leading 0.
- MM-dd: The month and day, with leading 0s.
- dd: The day component of a date profile field, with a leading 0.
Date formatting can be used along all date specific operations like is, isNot, onOrBefore, onOrAfter, and between.
The ww pattern represents the ISO week number, which follows the ISO-8601 standard. According to this standard:
- A week starts on Monday
- The first week of the year (week 01) is the week that contains the first Thursday of the year
- If January 1st falls on Monday, Tuesday, Wednesday, or Thursday, it belongs to week 1 of the new year
- If January 1st falls on Friday, Saturday, or Sunday, it belongs to the last week of the previous year.
Supported operators & nesting
When you want to combine rules, add && (for and) or || (for or) between the rules. Examples:
- user.firstname.in(“John”) && user.lastname.in(“Doe”) applies to all users who are named John Doe
- user.firstname.in(“John”) || user.lastname.in(“Doe”) applies to all Johns and all Does
In advanced view you can also nest rules to build more advanced rules. Examples:
- user.firstname.in(“John”) || user.lastname.in(“Doe”) ) && user.department.in(“Sales”) applies to all Johns and all Does who are members of the Sales department
Please note: If your advanced rules use syntax not supported by the Visual editor, you won’t be able to go back to the Visual editor.
Comments
0 comments
Please sign in to leave a comment.