I'am using Google App Script and Google Spreadsheet onOpen() trigger. I'm locking logged in user in Google Spreadsheet.
The restriction for the same is that it's not logging email id on cross domain which I found on forums.
Here is the code for the same:
function onOpen(e)
{
try
{
var ui = SpreadsheetApp.getUi();
ui.createMenu('Action')
.addItem('Add Data', 'addData')
.addToUi()
var sheet =SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Login Details");
sheet.appendRow([Session.getActiveUser().getEmail(),new Date()]);
}
catch(e)
{
Logger.log(e);
}
}
One observation from onOpen() functionality :
1] I'm owner of spreadsheet and it only logs the email ids of our company domain. (Automatically onOpen() of spreadsheet)
2] From other domain when I open bounded script of spreadsheet and run onOpen() then it logs the logged in user.
What is reason behind the same and is there any workaround for user on cross domain?