Appearance
Conditions
Conditions are used to automatically control when certain actions should or shouldn't occur in your App.
For example:
- You might only want to render a certain UI Component if certain pieces of data in a Data Object or Data List meet certain criteria.
- Or you might only want to execute a Webhook Transform if certain fields in the webhook payload meet certain criteria.
Heads Up
- Conditions do require you to write some extremely simple code in order to tell the system when you want certain actions to occur.
- If you're not comfortable writing code, don't worry! We've made it as simple as possible.
- And for those who are more comfortable with code, it's worth knowing that under the hood, we're using a very small subset of JavaScript to evaluate conditions.
Condition Syntax
Conditions are written with a very small subset of JavaScript. They are usually made up of simple comparisons between values. Here's an example of a simple condition where we're checking if the value of a field in a Data Object is equal to a certain value:
json
{
"action": "set",
"resourceType": "site",
"module": "jira:issueContext",
"title": "my_first_app",
"conditions": ["dataObjects.project.system_status.website == 'Online'"],
"componentData": {
"type": "StackedInformationGroup",
"title": "My First App",
"children": [
{
"type": "FieldValue",
"key": "App Name",
"value": "My First App"
}
]
}
}
Negative Conditions
You can also use negative conditions by adding a !
in front of the =
to check if a value is NOT equal to a certain value.
json
{
"action": "set",
"resourceType": "site",
"module": "jira:issueContext",
"title": "my_first_app",
"conditions": ["dataObjects.project.system_status.website != 'Online'"],
"componentData": {
"type": "StackedInformationGroup",
"title": "My First App",
"children": [
{
"type": "FieldValue",
"key": "App Name",
"value": "My First App"
}
]
}
}
Number Comparisons
You can also compare numbers in conditions. Here's an example where we're checking if the value of a field in a Data Object is greater than a certain value:
json
{
"action": "set",
"resourceType": "site",
"module": "jira:issueContext",
"title": "my_first_app",
"conditions": ["dataObjects.project.system_status.websiteResponseTime > 1000"],
"componentData": {
"type": "StackedInformationGroup",
"title": "My First App",
"children": [
{
"type": "FieldValue",
"key": "App Name",
"value": "My First App"
}
]
}
}
The full list of number comparisons you can use are:
>
Greater than<
Less than>=
Greater than or equal to<=
Less than or equal to==
Equal to!=
Not equal to
Multiple Conditions
Entities that support conditions can have multiple conditions. In this case, all conditions must be met for the condition to pass. Each condition is written as a separate string in the conditions
array.
json
{
"action": "set",
"resourceType": "site",
"module": "jira:issueContext",
"title": "my_first_app",
"conditions": [
"dataObjects.project.system_status.website == 'Online'",
"dataObjects.project.system_status.api == 'Offline'"
],
"componentData": {
"type": "StackedInformationGroup",
"title": "My First App",
"children": [
{
"type": "FieldValue",
"key": "App Name",
"value": "My First App"
}
]
}
}
"AND" vs "OR" Conditions
While separate conditions are always evaluated as an "AND" condition, you can use the &&
(AND) and ||
(OR) operators within a single string to create more complex conditions.
- The example below checks that either the
website
status isOffline
OR theapi
status isOffline
.
json
{
"action": "set",
"resourceType": "site",
"module": "jira:issueContext",
"title": "my_first_app",
"conditions": [
"dataObjects.project.system_status.website == 'Offline' || dataObjects.project.system_status.api == 'Offline'"
],
"componentData": {
"type": "StackedInformationGroup",
"title": "My First App",
"children": [
{
"type": "FieldValue",
"key": "App Name",
"value": "My First App"
}
]
}
}
You can combine multiple conditions with &&
(AND) and ||
(OR) operators to create more complex conditions.
- The example below checks that the
website
status is either "Online" or "Offline" AND that theapi
status is either "Online" or "Offline".
json
{
"action": "set",
"resourceType": "site",
"module": "jira:issueContext",
"title": "my_first_app",
"conditions": [
"dataObjects.project.system_status.website == 'Online' || dataObjects.project.system_status.website == 'Offline'",
"dataObjects.project.system_status.api == 'Online' || dataObjects.project.system_status.api == 'Offline'"
],
"componentData": {
"type": "StackedInformationGroup",
"title": "My First App",
"children": [
{
"type": "FieldValue",
"key": "App Name",
"value": "My First App"
}
]
}
}
Using Lists in Conditions
You can also use lists in conditions to see if a value does or doesn't match any of the values in the list.
The example below checks if the website
status is one of either Online
, Offline
, or Unknown
. If the values is anything other than those three, the condition will not pass.
json
{
"action": "set",
"resourceType": "site",
"module": "jira:issueContext",
"title": "my_first_app",
"conditions": ["['Online', 'Offline', 'Unknown'].includes(dataObjects.project.system_status.website)"],
"componentData": {
"type": "StackedInformationGroup",
"title": "My First App",
"children": [
{
"type": "FieldValue",
"key": "App Name",
"value": "My First App"
}
]
}
}
Similarly, you can check if a value is NOT in a list by adding a !
in front of the expression.
- Note that with things like the
includes()
operator, there is no=
sign, so the!
goes in front of the entire expression. - e.g.
![...list].includes(value)
json
{
"action": "set",
"resourceType": "site",
"module": "jira:issueContext",
"title": "my_first_app",
"conditions": ["!['Online', 'Offline', 'Unknown'].includes(dataObjects.project.system_status.website)"],
"componentData": {
"type": "StackedInformationGroup",
"title": "My First App",
"children": [
{
"type": "FieldValue",
"key": "App Name",
"value": "My First App"
}
]
}
}