Download page Checking if the specific tables exist.
Checking if the specific tables exist
Use case
You have two tables:
T1 with issues (issue keys plus some additional data)
T2 with defects (defect keys plus some additional data)
The T1 table is always present. But the T2 table may be or may not be present at all (no defects - no table). It can happen, for example, if you use the Jira Issues macro to generate tables.
If the T2 table exists, then each defect is linked to the specific issue from the T1 table (see the T2.'Linked Issue' column on the first screenshot).
You need to get the "issue-defect" list with all the additional fields from both tables if there are any defects. If everything is okay, you need to avoid SQL query errors and print the "No Defects" text.
Solution
Switch the page to the edit mode.
Insert the Table Transformer macro and paste the tables or the macros outputting tables within the macro body.
Select the macro and click Edit.
In the Presets tab select Custom transformation and click Next.
Enter the following SQL query:
IF OBJECT_ID("T2") IS NOT NULL
SELECT * FROM T1 JOIN T2 ON T1.'Key'=T2.'Linked Issue'
ELSE
SELECT FIRST("No Defects") AS 'Defects' FROM T1
SQL
Go to the Options tab.
Enable the Show result as plain text option.
Save the macro and the page.
The behavior when both the T1 and T2 tables are present:
The behavior when only the T1 table is present:
Cookie Notice
This website uses cookies for analytics, personalization and advertising. By continuing to browse, you agree to our use of cookies. Learn more