Retrieving Filter Condition in AppSheet

Hello!

Well, I created an action (go to another view within this app) that redirects the user to a filtered view using LINKTOFILTEREDVIEW(). Is there a way to retrieve the filter condition being applied in this view?

To provide some context, my app includes a list of classes, each with enrolled students (Related enrollments). I've created that custom action within a view based on the class table, and it successfully redirects users to the filtered view (when I click, show me the students that are enrolled in this class). It kinda works as a security filter. However, I need to access the filter condition being applied, for example, to display it in a virtual column on the target view (in this case, a view based on the student table).

I've explored the use of the CONTEXT() function, but it doesn't seem to provide the filter being applied to the table. I would like to get a piece of information that translates to something like "you've clicked on 'class name' ".

Thanks in advance.

0 3 77
3 REPLIES 3

You can create a 'show' or 'text' column that displays the information being used in the LINKTOFILTEREDVIEW() function. Something like:

"You've clicked on "&[_thisRow].[className]

If you provide some screenshots of your LINKTOFILTEREDVIEW() function, or of your data structure, I am happy to try to be more helpful!

I came up with a solution (an ugly one). 

It's an attendance app. Here I have a view that shows the classes added to the app:

jerewp_0-1709830024359.png

Clicking a row redirects you to another view, displaying a table of students enrolled specifically in that class***. This view allows you to mark their attendance for the selected class, today:

jerewp_2-1709831235370.png

 

 

All good. The filtering part was straightforward. As you can see, I have two actions for each student: add a row to another table, setting attendance column with a true or false value. The challenge arises when I land on that specific view of the student table: how does the app determine which class I've selected? This becomes a real issue when a student is enrolled in more than one class. Here is why:

What if I wanted to count how many absences the students have? All I have to do is to count it, checking in the attendance table (in the attendance column, count false entries), aggregating the count based on their ID, right? The problem, again, is when a student is enrolled in more than one class. Even before that, to which class should the attendance be attributed?

If I create another view of the table student (absences), filtering them by class (***the same ideia from above), where  it will display their names and absences count, it will count the absences from ALL the classes he is enrolled, obviously.

This is the reason why I need to determine which "row of the table class" the user clicked before landing on the current view (for this app, a filtered view of the table student). It's as if I wanted to know what is the filter condition being applied.

To address the challenge of identifying the selected class, I created another column in the student table (TEMP_CLASS). I implemented a data action triggered when the class is selected. This action updates the TEMP_CLASS column, in the student table, with the ID of the clicked class. Essentially, it stores the selected class information for each student, allowing us to track specific class absences later. If the student is enrolled in more than one class, it will be updated based on the clicked row. The formula for counting the absences will consider only the absences referred to the TEMP_CLASS value:

jerewp_3-1709832173832.png

Thank you for taking the time to read this, and I'm open to any new ideas you may have.

An 'ugly solution' that works is a beautiful one to me! 

I am curious, what tables do you have - Classes, Students, and attendance? It seems to me that if you are adding a new record to the attendance table that is specific to the student and the class, then it would be easy to collect the data you are looking for. Why doesn't the attendance table have a column for the class? 

Sorry if misunderstood still! Happy you have a solution

Top Labels in this Space