Configuring Custom Action Visibility¶
The action bar with conditional visibility is here and with these examples we will demonstrate how to configure custom action visibility on the Object General View.
While adding actions and setting custom visbility on those actions is done in the General view, any actions that are added, and that meet the visibility conditions that you set, will show up in the action bar on the Object Card.
With this you will be able to quickly create custom conditions for visibility of actions and the action bar will only render the actions on limeobjects that meet the criteria that you set. These conditions are written in the form of filter queries.
Here we'll cover various supported operators and provide examples and use cases.
Default Condition Function¶
Most use cases can be covered by the default limeobject-matches-filter
condition. As the name suggests this function takes in a filter query with one or more expressions.
Read more about filters here
If the limeobject matches the filter, then the condition is returned as true
and the Action will show in the action bar.
Supported Operators¶
- NOT (!)
- EQUALS (=)
- NOT_EQUALS (!=)
- GREATER (>)
- LESS (<)
- IN (IN)
- BEGINS (=?)
- LIKE (?)
- LESS_OR_EQUAL (<=)
- GREATER_OR_EQUAL (>=)
- ENDS (=$)
The "AND" and "OR" operators can used to combine two or more expressions.
- AND (&)// (1)!
- OR (|)// (2)!
-
- Specifies that multiple expressions must return true.
-
- Allows for one of multiple expressions to return true.
Visibility in the config¶
The new conditional visibility is housed under general config -> promotedActions -> visibility
for any given promoted action.
Here's an example of the expected structure of a config with a promoted action.
A visible promoted action will show in the action bar on the object Card in the webclient.
"promotedActions": [
{
"id": "my-action-id",
"label": "my-action-label",
"icon": "my-action-icon",
"color": "my-action-icon-color",
"params": {},
"visibility": {
"conditionID": "limeobject-matches-filter",
"conditionParams": {
"key": "done",
"op": "=",
"exp": true
}
}
}
]
Syntax Guidelines¶
Conditional visibility filters use the same syntax as the filters for Lime query.
Read more about Lime query here
Queries must be written in valid JSON.
{
"op": "must be one of the two supported operators (AND | OR)",
"exp": [
{
"key": "must be a valid property on the limetype",
"op": "must be one of the supported operators",
"exp": "must correspond to the property field type, e.g: boolean/text/number"
},
{
"key": "must be a valid property on the limetype",
"op": "must be one of the supported operators",
"exp": "must correspond to the property field type, e.g: boolean/text/number"
}
]
}
Incorrect Syntax¶
Only supported Operators can be used
If there is no key, or the key is null, the condition will fail
Expressions must be wrapped in an array when multiple expressions are present
Configuring Conditions¶
Using the default condition limeobject-matches-filter
should cover most use cases.
Below we give some examples of how to use it.
Using the Custom Condition Picker¶
The custom condition picker has 3 options. Follow the steps below for each option:
This is the default setting. When 'Always' is selected and saved the condition_id and condition_params will be set to null in the config and the action will always show in the action bar.
Select the property (e.g., "status," "priority," or any other property) that you want to base your condition on.
Choose one of the supported operators.
The picker will only list operators that are supported.
Specify the value you want to compare your property to. This value could be a number, text, or a list of values, depending on your chosen field and operator.
Note: If you chose the "Empty" operator, you would not have to input a value and with the "Empty" operator the picker should in fact not allow a value to be added.
With your property, operator, and value chosen, you can now save your custom condition.
You can also use the filter pickers in the webclient to generate your condition queries and copy/paste the code into the custom condition picker
You can write your own condition filters using JSON in the code editor of the Custom Condition Picker.
Add the condition ID, the default condition ID is 'limeobject-matches-filter'.
Use the code editor to write your custom condition query.
Simple conditions¶
The example keys used in these examples might not exist on limetypes, they are simply for showing the correct syntax to use.
Filtering on text values¶
Using NOT (!) to negate an expression¶
Complex Conditions¶
Multiple expressions in one filter are allowed.
Suppose you want an action to show on a Todo.
You have two specific requirements.
This action must only be visible on Todo objects where a specific Company is a relation on the todo.
This action must only be visible and if the subject contains 'customer visit'.
Suppose you want to control the visibility of an action based on the object status.
You have two possible requirements and you want the action to show if at least one of these requirements matches the object.
You want to include the action on objects with either a "Pending" or "Approved" status.
In this example we have two separate filters and are using an AND operator to combine them both.
The requirements are:
- 'person' must be the specified person AND 'company' must be the specified company
- 'subject' must contain either 'follow up' OR 'call'
Suppose you want to only show an action on Todo objects where the following requirments are met.
The requirements are:
- The 'coworker' is not one of two coworkers.
- The Todo is Done.
- The 'subject' is not 'follow up'.
{
"op": "AND",
"exp": [
{
"op": "OR",
"exp": [
{
"op": "!",
"exp": {
"key": "person",
"op": "IN",
"exp": [
20901,
16082
]
}
},
{
"key": "person",
"op": "=",
"exp": null
}
]
},
{
"key": "done",
"op": "IN",
"exp": [
true
]
},
{
"op": "!",
"exp": {
"key": "subject",
"op": "?",
"exp": "follow up"
}
}
]
}
What Is Not Supported¶
Please note that there are certain limitations to configuring the custom visibility of actions.
Here we have specifics on those limitations and examples of configurations that will not work.
Conditions cannot involve asynchronous operations or calls.
Conclusion¶
- The default condition 'limeobject-matches-filter' and supported operators will cover most use cases.
- Queries are written using the same syntax as filters in Lime Query, with some limitations.
- The Condition picker allows you to flexibly configure custom action visibility from the General View Config.
- Actions that meet the criteria set in your condition filters will show in the action bar on the object Card.
With these guidelines in mind, you can create custom conditions to precisely control when actions are displayed in your application's Action Bar.
Enjoy the flexibility and customization possibilities that custom conditions offer!