0

Open Record based on UserName

Good morning!

I am trying to make my database more user friendly and was wondering the following.

I have a table called Timesheet. I have a dashboard too. When a user clicks the "Login" button on the dashboard it opens up a new record in timesheet where they fill in the date, Time and they select their name from a related table "Staff".

Now I'd like them to be able to log out the same way. So click the Logout button on the dashboard to open the last record in Timesheet that they created. I was trying to use the userName() function, but this doesn't seem to be working. Is there anyway that I can use to have them up the last record they created in Timesheet?  I have tested this with the last(select Timesheet) but that just opens the last record irrespective of who created it.

 

THanks for your help once again!

8 replies

null
    • Daniel_Berrow
    • 6 mths ago
    • Reported - view
    let t := this;
    openRecord(last(select Timesheet[Staff.name = t.'created by']))
    

    This is assuming your username is the same as what it is stored as in the staff table, otherwise

    let t := this;
    openRecord(last(select Timesheet[userName() = t.'created by']))
    
      • John_Wilmans
      • 6 mths ago
      • Reported - view

       Hey again mate. Thanks for all the help. Unfortunately this isn't working and I don't know why! There are no code errors, it just doesn't do anything when I click the button?

      • Daniel_Berrow
      • 6 mths ago
      • Reported - view

      are you already in the last record that they created when you're pressing this? try replacing openRecord with popupRecord to see if it is just pointing to the same record

      • John_Wilmans
      • 6 mths ago
      • Reported - view

      Hey mate. Ok..so I may have got it to work. I have replaced Staff.name or userName with userId! Now it all seems to work fine. I have no idea why this works when userName or user doesn't.

       

      Thanks for your help man. It is hugely appreciated

    • Fred
    • 6 mths ago
    • Reported - view

    May I suggest that you use your dashboard (or new pages) to show the data that you want to show, instead of pulling up the record and exposing your raw data to your end users. As we know we can't trust users. 😉

      • John_Wilmans
      • 6 mths ago
      • Reported - view

       Funny enough I’m just following your instructions and watching about this on Nioxus!!!  

      • John_Wilmans
      • 6 mths ago
      • Reported - view

       I have actually pushed back the launch of the app a few months so I can get this Dashboard stuff right first. So any suggestions would be hugely appreciated. 

      • Fred
      • 6 mths ago
      • Reported - view

      if you have any questions please start a new post. 

Content aside

  • Status Answered
  • 6 mths agoLast active
  • 8Replies
  • 62Views
  • 3 Following