Hello Community,
I am currently working on a formular for Jira Automation which is supposed to create a work item with a table in the description.
The content of the description comes from {{webhookData}}, so I am using a Webhook.
My formular currently looks like this:
||Business Name|{{ltWebhookData.businessName}}|
||Score|{{ltWebhookData.payload.Score}}|
||Workbench Id|{{ltWebhookData.payload.Workbench Id}}|
||Model|{{ltWebhookData.payload.Model}}|
||Model Severity|{{ltWebhookData.payload.Model severity}}|
||Impact scope details|h3. Desktops
{{#ltWebhookData.payload.Impact scope details.Endpoint - Desktops}}
* Hostname: {{Hostname}}
* IPs: {{Ips}}
* Guid: {{Guid}}{{^last}}\\{{/}}
{{/}}|
|| |h3. Servers
{{#ltWebhookData.payload.Impact scope details.Endpoint - Servers}}
- Hostname: {{Hostname}}
- IPs: {{Ips}}
- Guid: {{Guid}}{{^last}}\\{{/}}
{{/}}|
|| |h3. Accounts
{{#ltWebhookData.payload.Impact scope details.Accounts}}
- {{.}}{{^last}}\\{{/}}
{{/}}|
||Link|{{ltWebhookData.payload.Link}}|
The problem I am facing is a broken table layout when "Endpoint - Desktops" or "Endpoint - Servers" is empty.
Is there a way to check that with an "{{if}}" in my formular? I tried that but only received errors.
Thank you for your help :D
Assuming the JSON is well-formed and recognized as JSON by the rule, you may still need to experiment to confirm / manage the behavior. The reason is some nested lists / list iterators in rules do not work consistently with all expectedly-possible functions. That is, some nested values evaluate as text in some context and not as lists.
I recommend using a simple test with conditional logic using the single-section {{#if(...)}} ... {{/}} format of the conditional, writing the results to the audit log to confirm both the syntax and the table markup layout.
If you instead try the {{if(condition, "when true", "when false")}} format of the function, that likely will not work with nested list iterations.
And, I suggest explicitly testing the list rather than relying on the isEmpty() function for lists. For example:
{{#if(someList.size.gt(0))}}
then do something
{{/}}
Kind regards,
Bill
Hello @Jeroen Poismans
thanks again for your help.
I managed to get a solution for my problem by changing the formula a bit.
I removed the headings for the table from the iteration of my JSON and also moved the last "|" for each row outside the iteration. So now I dont have to check anymore if the list is empty or not and the table gets rendered correctly.
Thanks again for your help. I learned a lot from that :D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
You can, but the exact implementation depends on the structure of your JSON (the webhook payload) that you receive in your automation rule.
If the fields you mention are JSON arrays, you could parse them to a list (this type is known in automation) and then use the isEmpty() to display sections conditionally or at least test on it in an automation condition to then render a different table.
Automation list documentation:
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#list.isEmpty
Could you share an example JSON (with dummy data of course)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your respone.
I had a look at the documentation earlier but did not manage to get it to work.
This is the JSON I am currently testing with:
{
"businessId": "abcdef-123456879-ghijkl-01234",
"businessName": "Company Name",
"title": "Company Name | [Test Message] Workbench | Alert Severity: -- | Score: -- | Model: -- | WB-XXXX-XXXXXXXX-XXXX | abcdef-123456879-ghijkl-01234",
"type": "Trend Vision One | Workbench - Workbench Alerts",
"payload": {
"Score": 0,
"Workbench ID": "--",
"Model": "--",
"Model severity": "--",
"Created": "--",
"Number of desktops": 0,
"Number of servers": 0,
"Number of accounts": 0,
"Number of cloud workloads": 0,
"Cloud Workload count": 0,
"Impact scope details": {
"Endpoint - Desktops": [
],
"Endpoint - Servers": [
{
"Hostname": "--",
"Ips": [],
"Guid": "--"
},
{
"Hostname": "--",
"Ips": [],
"Guid": "--"
}
],
"Accounts": ["--", "--"],
"Mailboxes": ["--"],
"Cloud workloads": [
{
"Resource ID": "",
"Resource name": "",
"Workload type": ""
}
],
"Containers": [
{
"Container ID": "",
"Container name": ""
}
],
"CloudIdentities": [
{
"CloudIdentity ID": "",
"CloudIdentity name": ""
}
]
},
"Link": "--"
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please keep in mind that we are in different time zones and replies do not come instantaneously. Just to make sure, got it fixed?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.