Can I solve this without a session variable?

teambelair
Participant V

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 9 629
9 REPLIES 9

MultiTech
Participant V

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

3X_7_b_7bd56175e639d667cfed27b076557e5f8c69c62e.gif

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?

MultiTech
Participant V

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.

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.
3X_7_3_736fa967c966b87df97c816156c23710ed8a8682.jpeg

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)

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)

MultiTech
Participant V

@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.

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!

Perhaps this is your problem:

teambelair
Participant V

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

Top Labels in this Space