New Bug Encountered: Counter gets back its initial value

Hi All,

I build a counter that shows the number of card and time left (see on the top left of the gif)

It works great but when I wait a bit, the counter gets automatically reinitialized for no reason. I can’t figure why. Since this class has very few exercises, the class duration is only 1 minute. For bigger class, the same issue occurs for the time left.

Here are the field definitions:

The counter field is called “Formatted Summary Class In Progress”.

  • Type: Text
  • Expression:
    COUNT([Class Cards])-[Cards Completed] & " card left" & " • " & [Formatted_Duration_Left] & " left "

[Class Cards]:

  • Type: List
  • Expression: REF_ROWS(“Class_Cards”, “Class_Board”)

[Cards Completed]:

  • Type: Number
  • Expression:
    COUNT(
    SELECT(
    Class_Card_Logs[Key]
    ,
    [Class_Log]=INDEX(SELECT(Class_Logs[Key], AND(NOT([Fast Class]), [Device]=CONTEXT(“Device”), [Status]=“In Progress”)), 1)
    )
    )

[Formatted_Duration_Left]

  • Type: Text
  • Expression:
    ROUND(TOTALMINUTES(SUM(SELECT(Class_Cards[Duration], IN([Key],[_THISROW].[Class Cards In Progress])))))& " mins"

Thank you!

Any help on that?

I don’t know if it is a normal approach, however what I did for card view is having a separate VC just for doing calculation and another VC for doing the text with app formula CONCATENATE("Blabla", [CalcVC]).

2 Likes

got it. Will try that and get back to you.

One more thing you may wish to consider is that in the expression

COUNT([Class Cards])-[Cards Completed]

to show number of cards left, the part COUNT([Class Cards]) seems to remain intact because the “cards left” number resets to the orginal highest number that comes from [Class Cards] column.

So the column [Cards Completed] seems to reset back to zero.

Thus if you are testing the expression in the emulator, I believe the CONTEXT(“Device”) used in the expression of the column [Cards Completed] could be creating an issue.

I suggest you test the expression on a mobile device. This is so because in the emulator, following behavior of the CONTEXT('Device") expression is mentioned. So in emulator testing the device UUID could restting the value of [Cards Completed] to zero.

Quote from the article: In the emulator of the app editor, the value is randomly generated each time the editor is loaded or changes are saved.

2 Likes

Thanks @Suvrutt_Gurjar but I have seen the bug happening on the mobile app as well

Oh, ok, thank you for the update @teambelair.

In general, since it is the second part of expression that seems to be failing, it may be good idea to to test by eliminating each of the subexpression parts, starting with CONTEXT(“Device”)

Can the expression be tested without CONTEXT(“Device”)?

1 Like

You are right. I updated the expression of [Cards Completed] by removing the CONTEXT(“Device”) and it works fine. The counter doesn’t get reset.

COUNT(
SELECT(
Class_Card_Logs[Key]
,
[Class_Log]="Hardcoded_key"
)
)

What’s the best way to share this bug with appsheet?

I can’t think of any workaround since I have to use CONTEXT(“device”) to identify the current user session.

Nice to know that the issue is now known.

Well, I believe the CONTEXT() functions in general , as the name suggests, work for that particular CONTEXT(), either a view or view type or device. So those need to be used with that understanding.

So it may not be a bug but possibly a particular condition during which the CONTEXT() function is not applicable and thus the expression fails.

You may write to support@appsheet.com for guidance. or you may start a new post thread by stating the exact problem ( now identified with CONTEXT(“Device”) ) so that some community colleague could share insights.

3 Likes

Thanks, I sent an email to the appsheet support.

During my testing, it seems that the CONTEXT(“Device”) is “stable” when utilize it with a Security filter. The Chrome utilized is with a dedicated profile on a session, even when closing all tabs, shutdown and re-open chrome to re-open the test app, it still showing the intended record per the CONTEXT(“Device”) that is specified.

3 Likes

I am on the PUBLISHER_PRO plan so I don’t have access to the Security filter. I’m adding my filter in the Row filter condition of the slices.

1 Like

@teambelair, Could you update if you are running the app in browser in mobile device or have you installed it in the mobile where you are testing it?

Edit: You may wish to check above because “Device” as a host seems to be working when the app is installed in the mobile.

Below are excerpts from the article -
Host : Gives Browser if the app is running in a browser or the app editor’s emulator, Device if a native app, or Server if used from an AppSheet server (e.g., in a workflow or report).

So you may wish to include iexpression something like below and test with the app insalled on the mobile device.
AND( CONTEXT(“Host”)=“Device” , CONTEXT(“Device”)=[Device])

Note : The above suggestion is untested.

1 Like

Thanks @Heru. That is a useful input. I believe it shall be useful to the community while testing CONTEXT(“Device”).
I believe your tip is worth sharing in Tips and Tricks section. You may wish to do that.

2 Likes

The app is mostly run on the whitelabel mobile app. I say mostly because power users do use it on web browser as well but the priority is on the app.

Also CONTEXT(“device”) is working fine. It’s just not working in this particular case where a virtual column calls a SELECT with CONTEXT(“device”) as a filter.

Ok, thank you for the updates @teambelair.

I have no further discussion points to share on this topic. I will definitely share if I am able to create similar test conditions and I find any useful observations to share.

1 Like

If:

Have your tried to split with a new VC:

SELECT(Class_Logs[Key], 
		AND(
			NOT([Fast Class]),
			[Device]=CONTEXT(“Device”),
			[Status]=“In Progress”)
		)

And the COUNT:

COUNT(FILTER("Class_Card_Logs",[Class_Log]=INDEX([NewVC]), 1))

1 Like