Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confiforms filter view dynamically with current page

Jens Jakobi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 10, 2021

Hello,

I have the following setup:

I have a form named "application" which holds data about an application. When a new entry is created, this form creates a new page tree for the new entry by using several IFTTTs macros. The pages themselves are using templates, which are passed to the IFTTT in the macro body. The form also creates entries for all sub forms.

I have a second form named "common" which holds some specific data about the applications, which are in the first form. The common form works as sub form of the application form. One of the stored fields in the common form is "page" where I store the confluence page on which the view is located. 

So when I create an application I get a application form entry, a corresponding common form entry and a page for the common data. This setup works fine so far. 

Now my new requirement is this:

I need to gather additional contact information to my common data. This data shall be organized or structured in a certain way (or in other words: I don't want to allow free text). To achieve this I created a second form named contacts which holds classic contact information like firstname, lastname, phone number, etc.

My requirement would be to use something like nested forms where I create a new application entry which creates a new commin entry and when I edit a common entry I can create a new contact entry "on-the-fly". But as this is not possible with Confiforms (no nested forms), I decided to try another way. My idea is this:

  • I added a contact registration control and a contact view on the page where the common view is located.
  • I create new contact entries on the common page and when the entry is created I just automatically set a hidden field "page" with the page I am currently showing using an IFTTT macro in the form.
  • In the contact view on the common page I filter the entries by this page field and only show the entries which have the same page id as the page which is currently shown. I wanted to achieve this by using the [entry._page] variable.

This seemed to work, but I have a problem now. Because I use a page template in the initial creation of the common page the [entry._page] variable gets evaluated in that situation and I get a wrong page in my contact view filter. This results in an empty contact view as no entry has that page id.

I also tried a form filter macro, but in the end it was the same problem with the evaluation of the [entry._page] before the page is shown. But I do not want to show any form filter macro to the user (but i guess it can be set invisible).

My questions are now:

  1. Is it possible to filter a view dynamically using the macro body of the view?
  2. Is there any other way to filter the view dynamically based on the current page in my scenario where I use a space template to create the common page?

edit: As this setup is quite big I did not create a working example or attached storage format code. If this is necessary I can provide this.

2 answers

1 accepted

0 votes
Answer accepted
Alex Medved _ConfiForms_
Community Champion
August 10, 2021

You can use asEntryRef function in your template, so when the page gets created the function gets evaluated and you get the output as [entry._page]

[entry.id.asEntryRef(entry._page)]

(instead of [entry._page])

Alex

Jens Jakobi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 10, 2021

Hi Alex,

I just found that too. It works as intended! I hoped I would be faster than you with my answer, but I had no chance :D

Thank you!

0 votes
Andrey Khaneev _StiltSoft_
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 10, 2021

Hello Jens,

Is it possible to use page title instead of page id?

Another possible solution is to use the Table Filter macro with the @pageTitle variable.

And one more tip: maybe you could lookup two tables like in these examples.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events