Skip to main content
shobhits6437
May 12, 2025
Question

I have a requirement to display last login time for any user whenever they login to the application.

  • May 12, 2025
  • 4 replies
  • 0 views

Hello Folks,

I have a requirement to display last login time for any user whenever they login to the application. As we know, it's a site page, where-in a user lands whenever they login, and a process can be triggered only with user interaction.

Is there any way to implement this?

Any suggestion/help is highly appreciated. Thanks in advance!

Thanks Shobhit.

    4 replies

    mikes0011
    Brainy
    May 12, 2025

    As in display the current time on the form they land on?  Couldn't you just show them the current time in that case?  If not, how does what you're thinking of differ from simply showing the current time on their landing page?

    Apart from that, it's always possible to scrape the login-audit.csv file for recent logins, pretty easily.  You could probably develop an expression rule that consumes a username, does its log file reading / data processing in the background, then returns the last login-audit timestamp.

    mikes0011
    Brainy
    May 12, 2025

    Just for an example, if you put the following into an expression rule (with a single text rule input called "username"), it should return the timestamp of the user's latest login time (if any).

    a!localVariables(
      local!auditRead: readcsvlogpagingwithheaders(
        csvPath: "login-audit.csv",
        startIndex: 1,
        batchSize: 100,
        headers: {"timestamp", "username", "success", "ip", "mode", "agent", "uuid", "something else"},
        filterColumName: "username",
        filterOperator: "=",
        filterValue: ri!username
      ),
      
      local!length: if(
        local!auditRead.totalCount > 0,
        length(local!auditRead.rows),
        null()
      ),
      local!rowValues: if(
        local!auditRead.totalCount > 0,
        a!forEach(
          local!auditRead.rows,
          split(fv!item, ",")
        ),
        null()
      ),
      
      local!date: index(
        index(
          local!rowValues,
          local!length,
          null()
        ),
        1,
        null()
      ),
      
      if(
        a!isNotNullOrEmpty(local!date),
        
        local(gmt(parsedate(local!date))),
        null()
      )
    )

    stefanhelzle0001
    May 12, 2025

    You could read this log file

    docs.appian.com/.../Logging.html

    shobhits6437
    May 13, 2025

    Thanks Stefan for sharing this.