Skip to content

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.

General View Config -> promotedActions -> visibility
"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.

Query with a single Operator and single Expression
{
    "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"
}
Filter with multiple Expressions
{
    "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"  
        }
    ]
}
Filter with a multiple Operators and a single Expression
{
    "op": "must be the NOT (!) operator",
    "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"
    }
}

Incorrect Syntax

Only supported Operators can be used

Incorrect syntax
{
    "key": "value",
    "op": "MORE_THAN",
    "exp": 20001
}

Use a supported operator

Correct syntax
{
    "key": "value",
    "op": ">",
    "exp": 20001
}

If there is no key, or the key is null, the condition will fail

Incorrect syntax
{

    "op": ">",
    "exp": 20001
},
{
    "key": null,
    "op": ">",
    "exp": 20001
}

Make sure a key exists

Correct syntax
{
    "key": "value",
    "op": ">",
    "exp": 20001
}

Expressions must be wrapped in an array when multiple expressions are present

Incorrect syntax
{
    "op": "OR",
    "exp": {
            "key": "value",
            "op": ">",
            "exp": 75000
        },
        {
            "key": "value",
            "op": "<",
            "exp": 150000
        }
}

Multiple expressions must be wrapped within an array

Correct syntax
{
    "op": "AND",
    "exp": [
        {
            "key": "value",
            "op": ">",
            "exp": 75000
        },
        {
            "key": "value",
            "op": "<",
            "exp": 150000
        }
    ]
}

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.

In the config, the visibility for 'always' shows like this
"visibility": {
    "conditionID": null,
    "conditionParams": null
}

Select the property (e.g., "status," "priority," or any other property) that you want to base your condition on.

Select Field

Choose one of the supported operators.
The picker will only list operators that are supported.

Select Operator

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.

Set Expression

With your property, operator, and value chosen, you can now save your custom condition.

Save Your 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. Custom Condition Editor

Simple conditions

The example keys used in these examples might not exist on limetypes, they are simply for showing the correct syntax to use.

Example: filtering on a boolean value
{
    "key": "done",
    "op": "IN",
    "exp": [
        true
    ]
}
Example: filtering on a relation
{
    "key": "person",
    "op": "IN",
    "exp": [
        20777
    ]
}

Filtering on text values

Example: Note begins with 'Follow up'
{
    "key": "note",
    "op": "=?",
    "exp": "Follow up"
}
Example: Subject contains 'demo'
{
    "key": "subject",
    "op": "?",
    "exp": "demo"
}
Example: Note ends with 'cancelled'
{
    "key": "subject",
    "op": "=$",
    "exp": "cancelled"
}

Using NOT (!) to negate an expression

Example: Note does not begin with 'Lime Technologies'
{
    "op": "!",
    "exp": {
        "key": "note",
        "op": "=?",
        "exp": "Lime Technologies"
    }
}
Example: Note does not contain 'Energi AB'
{
    "op": "!",
    "exp": {
        "key": "note",
        "op": "?",
        "exp": "Energi AB"
    }
}
Example: Note does not end with 'follow-up.'
{
    "op": "!",
    "exp": {
        "key": "note",
        "op": "=$",
        "exp": "follow-up."
    }
}

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'.

Using 'AND' to combine multiple expressions that must return true
{
    "op": "AND",
    "exp": [
        {
            "key": "company",
            "op": "IN",
            "exp": [
                14771
            ]
        },
        {
            "key": "subject",
            "op": "?",
            "exp": "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.

Using 'OR' to combine multiple possible expressions one of which must return true
{
    "op": "OR",
    "exp": [
        {
            "key": "status",
            "op": "=",
            "exp": "Pending"
        },
        {
            "key": "status",
            "op": "=",
            "exp": "Approved"
        }
    ]
}

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'

Combining AND with an OR operator
{
    "op": "AND",
    "exp": [
        {
            "key": "person",
            "op": "IN",
            "exp": [
                20901
            ]
        },
        {
            "key": "company",
            "op": "IN",
            "exp": [
                2217
            ]
        },
        {
            "op": "OR",
            "exp": [
                {
                    "key": "subject",
                    "op": "?",
                    "exp": "Follow up"
                },
                {
                    "key": "subject",
                    "op": "?",
                    "exp": "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'.

Combining multiple operators is possible
{
    "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.

Condition filters cannot include nested property paths, such as 'deal.value.' or 'person.name'

Unsupported configuration:
{
    "key": "deal.value",
    "op": ">",
    "exp": 50000
}
Unsupported configuration:
{
    "key": "person.name",
    "op": "=",
    "exp": "Jane Doe"
}

Filters on aggregates are not supported.

Unsupported configuration:
{
    "key": "deal.sum_dealvalue_0",
    "op": ">",
    "exp": 3000000
}

The '$me' keyword is not supported.

Unsupported configuration:
{
    "key": "coworker",
    "op": "=",
    "exp": "$me"
}

This is currently not supported.

Unsupported configuration:
{
    "key": "date",
    "op": ">",
    "exp": "2023-01-01"
}

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!