Skip to main content
August 4, 2022
Solved

timer function in Interface?

  • August 4, 2022
  • 5 replies
  • 0 views

Hello.

I have and component(card layout) shown in the interface using showWhen() function,

and want it to disappear after 30 seconds.

I thought of using the showWhen() function and refreshInterval of refreshVariable, but couldn't make it work.

I'd appreciate it if you could let me know if there is a way to make this possible.

Thank you.

    Best answer by paulos0008

    You can achieve that without user interaction:
    There is a small issue, it's not exactly 30 seconds, because when you set the refreshInterval as 0.5, it is not exactly 30 seconds, but somewhere around it. From some tests I did, it's around 25 seconds.

    a!localVariables(
      local!timeFlag: now() + second() * 15,
      local!show: a!refreshVariable(
        value: now() < local!timeFlag,
        refreshInterval: 0.5
      ),
      a!cardLayout(
        showWhen: local!show,
        style: "WARN"
      )
    )

    5 replies

    stefanhelzle0001
    Brainy
    August 4, 2022

    Try something like this. The important part is, that you cannot make this work without a user interaction.

    a!localVariables(
      local!status: true,
      local!show: a!refreshVariable(
        value: local!status,
        refreshOnReferencedVarChange: false,
        refreshInterval: 0.5
      ),
      {
        a!buttonArrayLayout(
          buttons: {
            a!buttonWidget(
              label: "hide",
              value: false,
              saveInto: local!status
            )
          }
        ),
        a!cardLayout(
          contents: {},
          height: "AUTO",
          style: "SUCCESS",
          marginBelow: "STANDARD",
          showWhen: local!show
        )
      }
    )

    August 4, 2022

    Thank you.

    I hope there is a way to make this work without a user interaction.

    October 27, 2022

    You can achieve that without user interaction:
    There is a small issue, it's not exactly 30 seconds, because when you set the refreshInterval as 0.5, it is not exactly 30 seconds, but somewhere around it. From some tests I did, it's around 25 seconds.

    a!localVariables(
      local!timeFlag: now() + second() * 15,
      local!show: a!refreshVariable(
        value: now() < local!timeFlag,
        refreshInterval: 0.5
      ),
      a!cardLayout(
        showWhen: local!show,
        style: "WARN"
      )
    )

    stefanhelzle0001
    Brainy
    October 27, 2022

    Hm ... as simple as this is, I did not think of it. Thanks a lot :-)

    mikes0011
    Brainy
    October 27, 2022

    Yeah, I tried it too and it seems to work fine.  I would've guessed, though, because I already have a similar functionality in place on some of my interfaces to "expire" a document download link for an exported report that I have the process auto-delete after an hour has elapsed.

    The Expression Guru