A signed-in user edited a form but was recorded in another user's row

My app’s URL: https://xfyel.glideapp.io/
and https://rj7na.glideapp.io/

Hi everyone, specially to the Glideapps programmers!

We are testing an attendance application that we made for remote Time Recording. Things are going well but there are some reports that users cannot log out. In my investigation, I found out that another user was able to log him out. The app was filtered to only edit the one’s that the signed-in user owns. I also tried checking the cell’s history, still it can be said that the editing has a bug.

Please help me on this issue. A button with a link to a screen using relationship directs the user to the edit form, im not sure if this is a bug using the relationship or there are other issues that i do not know.

Thank you for your response in advanced!

Hi, may I have a reasoning to use a button that leads to a relationship screen for editing, instead of a form button or an edit option (pencil icon)?

The button is coming from a User Profile. We have two buttons, Log-in and Log-out buttons, which is visibly interchanging depending on it’s state. Log-in button is a form button that adds log-in time, log out button, goes to that form and then there an edit button is pressed to log the time for log out.

So basically the buttons are there to help users understand that they are doing an action (log out/ log in), and to basically ease them from searching their names (on a calendar view) for them to edit and save the log out time.

But then there have been two occurrence wherein the edited row wasn’t on the signed-in user’s row.

I have just had a quick look on your app, so if I understand right, each log in creates a new row in your sheet at the start of their day, then at the end of their day you want the employee to come back into the app and edit that same row to record their log out. Is that correct?

Yes that is correct. We started testing it, for the hundreds that logged in, there have been two times that a user logged out someone else’s account. There is a filter on which only the row owner can edit his (signed-in user filter). I checked the relation column, and there is only one is to one relationship between the user profile tab and the OnDuty Tab. I wonder if a rowid needs to be used to avoid issues/bugs like that. Or if there are other things causing the issue.

What are your relation settings? What is your “matching” column between the two sheets?

In the user profile, there is an employee pin (which is unique to every employee) and when filling up the other sheet(on duty), the employee pin is automatically included to one of the columns. With that i made a relations column between those sheets. Relationship will be disconnected during log out/edit, because a unique value from glide will overwrite the column used for relationship.

Let me propose my workflow for your case, hope it makes sense and would be better for your employees as well:

  • User logs in at the start of their work, create a new line in the “On duty” sheet by submitting a form. That form retrieves their unique employee ID, and the timestamp.

  • Have a multiple relation matching the unique ID in the employees sheet to the IDs in the “On duty” sheet. Have visibility conditions to show only the logs for each employee sign-in (by filter email is signed-in user in the Profiles sheet, or setting row owner).

  • At the end of the day, the employee opens the app again, tick a checkbox that is a column in the “On duty” sheet. A script will be triggered to take the timestamp that checkbox is ticked and saved that as their log out time. This will be better instead of having an edit option in my opinion. After the checkbox is ticked, set visibility condition so that it will disappear.

Thank you for your inputs. Very much appreciated!
I shall try those suggestions and see how it will improve the process. Thank you very much again!

It’s late here I’m not on my laptop. Will help you with the script/live example if I have time tomorrow :smile:

I’m back with the script for this.

// The column you want to check if something is entered.
// Where you want the date time stamp offset from the input location. [row, column]
var LOGOUT = [0,1];
// Sheet you are working on
var SHEETNAME = 'Change test'
function LogoutTime(e) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  //checks that we're on the correct sheet.
  if(sheet.getSheetName() == SHEETNAME) { 
var selectedCell = ss.getActiveCell();
//checks the column to ensure it is on the one we want to cause the date to appear.
if(selectedCell.getColumn() == COLUMNTOCHECK && selectedCell.getValue() == true) { 
  var logout = selectedCell.offset(LOGOUT[0],LOGOUT[1]);
  if(initialcell.getValue() !== ''){
  logout.setValue(new Date());}

You have to change the COLUMNTOCHECK to the column where you have the logout checkbox as I have said yesterday. Here I’m setting it to column B (corresponding to numerical value 2).

The other thing that needs to be changed is the SheetName: var SHEETNAME = ‘Change test’

Chang the ‘Change test’ to your sheet name in the real app.

If you’re not familiar with scripts I can help setting it up.

Thank you for your guidance, I’m still relatively new to apps script but I am learning a lot here.

I tried somw tests last night and perhaps i found the reason why there is an error.

This is because perhaps of the function that deletes a row every 12 hours. While editing a row to record a log out, the rows are moving up due to the deletion, then the data will show up on a different row.

1 Like