Can I solve this without a session variable?

Hi All,

Looks like there is no session variable capability in Appsheet:

I wonder if I can solve my problem without it. See video:

Data model:

In summary, when the user clicks on a Class, I would like to set the selected class in a session var. Then when viewing Lesson Techniques, the status will be retrieved based on this session variable.

I tried the method 2 from Matt: Background Variable Table but it was too slow and too heavy on the DB.

I can’t find any alternatives other than creating a dedicated UX view per class to capture the context. This is clearly not a good solution since i will have to continually update the list of UX views whenever I add classes.

1 Like

Shouldn’t be slow at all, should be lightning fast actually

  • You should be able to change these background variables almost as fast as you can hit the buttons

In the GIF above, you can see how the two columns on the right update as I change the settings inside the left column

  • Notice how fast things change
  • This not only includes the actual data change to the database, but also the slices that drive the views update as well

All almost as fast as I can press the buttons.

There is, however, a sync for each data-change I make;

  • but if you design a system so users can keep moving forward, then you don’t have to worry about these.

@teambelair How did you set your “background variables” up, may I ask?

2 Likes

You might investigate LINKTOFILTEREDVIEW(), you might find something there that can help.

  • But it’s not going to persist in any way, it’s not a variable that’s stored somewhere, but it can take you to a view with limited records - instead of all of them.
1 Like

Hi Matt, Yes, I’m using LINKTOFILTEREDVIEW() on the table Class to show related Lesson Techniques records on top of adding a new record on this workaround table Class_Card_Status_Mappings.
2021-07-11_13-54-45

The problem is that I want the right Status to be displayed on the Lesson Techniques view.
So I added this heavy expression on the Status field:

INDEX(
	ORDERBY(
		FILTER(
			"Class_Card_Status_Mappings"
		,
			AND(
				[Lesson_Card]=[_THISROW].[Key]
			,
				[Class]=[_THISROW].[User_Profile_Session_Var]
			)
		)
	,
		[_RowNumber]
	,
		TRUE
	)	
,
	1
)

Expression of virtual field User_Profile_Session_Var:
INDEX(SELECT(User_Profile_Session_Var_Classes[Key], [Device]=CONTEXT("Device")), 1)

1 Like

@teambelair Are you collecting a separate record, per-gym/per-technique/per-user, for each completed technique?

If you’ve got a table that collects these records, which essentially connect the Gym, Lesson Technique, and the User together, then you’ll see a list of these records under each Lesson Technique.

  • If you create a (slice) that holds only the completed technique records that were done by the individual person…
    • then you can create a REF_ROWS() inside the Lesson Techniques table

What this accomplishes is it will create a unique filter, for each user based on the completed technique records they’ve entered into the system, for each Lesson Technique.

Instead of a brute-force method, this makes use of the efficiencies built into AppSheet.

Move this into a (slice)

Call it something like: “Current_Session” or something

You only need the following for the slice condition

[Device] = CONTEXT("Device")

From this, you can more efficiently call values from that record.

INDEX(Current_Session[Key], 1)
INDEX(Current_Session[User_Profile_Session_Var], 1)

1 Like

I have a record per class and technique (see status mapping table in the diagram). A Class is indeed associated to a gym.

These recommendations are great optimization but I actually can’t even make it work right now. I’ll get back to you tonight. Thanks Matt!

1 Like

Perhaps this is your problem:

2 Likes

was able to solve it with this dirty trick: Hack to refresh virtual column on records from another table

1 Like