How to get table id filtered by Table Filter from HTML page source?

Aster August 14, 2023

I am trying to use HTML macro to extract data from "Confiforms TableView combined with Table Filter" macro and show the content in plain text to serve as a table summary.
Like, we have a table of everyone's expense (filtered in some condition), and we'd like to be able to put a sentence like: "UserA spent the highest amount in last month."

However, seems like the table id in the page source is not fixed, and it changes every time when the page is refreshed. And I tried using "data-cf-form", but it will return unfiltered data.

Wondering if there's a way to come out the summary sentence?

Thanks!

2 answers

1 accepted

2 votes
Answer accepted
Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 21, 2023

Hi @Aster ,

Not sure if we got your ticket in our JSM or maybe it was some other customer (we got a similar question there), so I duplicate some hints here for other people to see if they come across this question: you may try to find your table and get the required data as plain text using javascript

tfTableSelector = "table.tf-macro";
document.querySelector(tfTableSelector).innerText;

In your script you need to specify the tfTableSelector, and the innerText option returns all the data, even the filtered out rows.

Note that our app also doesn't set or change any table IDs and table data.

And maybe this hint may come in handy - you can find and show specific cells as plain text using javascript and Table Transformer macro:

Mon 2-1.png

SEARCH AS @Cells RETURN(@Cells->[1]->key) FROM T1;

Mon 2-2.png

Hope this helps your case.

Aster August 26, 2023

Hi @Stiltsoft support

yeah I am the one asked this question in your JSM. For the first solution, using tfTableSelector, I just can't figure out which element I should use to get the filtered table. I think I will just give up on this...

The second solution is great! But if I'd like to add some words in front of the search result, like "Here is 2 - we want to find this cell." And combine 2 search results, like "2 - we want to find this cell and 1,2,5." Could you advise how to get them by Table Transformer?

Thank you!

Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2023

Hi @Aster ,

You may try the following SQL query:

SEARCH AS @Cells RETURN
(@Cells->[1]->key AS 'Some comment 1',
@Cells->[1]->Platform AS 'Some comment 2')
FROM T1;

Mon 3-1.png

Or if you want to have several entries as plain text, you may reuse your source table several times with the help of the Table Excerpt/Table Excerpt Include macros and use several Table Transformer macros with the queries from the previous answer.

So, you just manually type your description (for example, "Some comment 1") and then extract the required info using the Table Transformer wrapped above the Table Excerpt Include macro.

Aster August 28, 2023

Hi @Stiltsoft support

Can I simply add a few words, like "Here is", in the plain text result?

I am asking because the result I get now will be in the new line, so it doesn't look like a complete sentence to users, which makes it weird...

Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2023

You may use the second internal Table Transformer macro with this kind of query:

SELECT
"Some text we want to add " + 'key' + " Some thext we want to add" AS 'key',
"Some text we want to add " + 'Platform' + " Some thext we want to add" AS 'Platform',
"Some text we want to add " + 'Another' + " Some thext we want to add" AS 'Another'
FROM T*

Here we add some text before and after the cells' contents.

Mon 4-1.png

Then you use the first SQL query in the external Table Transformer macro and get the specific cell's contents.

My screenshot was taken for Confluence Cloud, so I nested my macros via the Table Toolbox macro. On Server/Data Center you wrap your macros directly one into another.

Aster August 29, 2023

Thanks a lot! It works well.

But if I'd like to add a space in front of some text, like: "   Some text we want", it will just ignore the spaces.

I tried a few way to add the space but still not able to. Could you advise how it can be done in the Table Transformer macro? Thank you.

Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2023

You may use some visible symbols that are not ignored by HTML, for example, a series of underscores:

"Some text we want to add______" + 'key' + "______Some text we want to add" AS 'key'

They will be shown as they are.

Aster August 29, 2023

Ok, got it. Thanks so much!

Like Stiltsoft support likes this
0 votes
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 15, 2023

Hi

Cannot tell much about the "table id", as this does not sound like something from ConfiForms app... but to approach your problem I would try to use the ConfiForms ValueView to get the aggregated and filtered number. I believe that should work

Or a separate TableViewMerger macro to show aggregated numbers

Alex

Aster August 17, 2023

Hi @Alex Medved _ConfiForms_,

By "table id", I mean the one that can be found in the page source. We are trying to capture the data in a filtered TableView macro, and put them in plain text as summary using HTML codes. Is there a example that ConfiForms ValueView might also be able to do that? Thanks!

image.png

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 17, 2023

If you need something unique and constant you can add a "class" to CSS parameter

Something like

class:iamunique

And then access the table using the class, AJS.$('.iamunique')

Alex

Like Aster likes this
Aster August 20, 2023

We can get the unique class from your suggestion. Thanks.

However, it will return the whole table instead of the filtered one...

Would you help to provide some suggestion on how we can capture part of the filtered table and put them in plain text as summary?

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 20, 2023

Sorry, I dont know anything about the "filtered one". Can help with ConfiForms specific questions... As I understand this is something what TableFilter plugin does

Aster August 21, 2023

No worries. Thanks for your feedback.

I edited the question so people familiar with Table Filter might see this.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events