0
votes

What I want to do is to place the user's email who is clicking the checkbox to true in the cell directly next to the checkbox that they're clicking on. I've got the code so that I can place my own email there. I've even played with it to the point where it will remove the "@gmail.com," but I cannot get this to show for other users.

I had it, at one point, placing the current users emails in the box, but then it would quickly change to my own. However, I don't remember the state of the code as it was then, and haven't been able to replicate it.

I've tried everything suggested here.

I've also referenced this post here.

Here is my code:

function createTrigger(){
ScriptApp.newTrigger('myFunction').forSpreadsheet(SpreadsheetApp.openById('1Y0-bpAhGzPSS5DIPnoZH4OcY2b9IL8LhvBfc2is0zVU')).onEdit().create();
}
function myFunction(e) {
  var groupOneCheck = 3;
  var groupTwoCheck = 7;
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  var checkCell = ss.getActiveCell();
  if (checkCell.getColumn() == groupOneCheck) {
    var dateTimeCell = checkCell.offset(0,2);
    var userCell = checkCell.offset(0,1);
    dateTimeCell.setValue(new Date());
    userCell.setValue([Session.getEffectiveUser().getEmail()]);
  }
  if (checkCell.getColumn() == groupTwoCheck) {
    var dateTimeCell = checkCell.offset(0,2);
    var userCell = checkCell.offset(0,1);
    dateTimeCell.setValue(new Date());
    userCell.setValue([Session.getEffectiveUser().getEmail()]);
  }  
}

I want to do the same thing for both of the if statements because they correspond to different columns.

Here is a link to the sheet that I am currently testing with.

1
Please explain what you trying to do in your own question without depending upon links to other questions.Cooper

1 Answers

2
votes

It works for me if I use an installable trigger because simple triggers cannot perform functions that require permission.