This is still not working for me. But, I wanna let it rest and come back to it later.
Now, I'm working on the login page. It has two buttons - 'Register' and 'Login'.
On clicking the 'Register' button, the user will be registered in the firebase. Since, the user is new, we create a new sheet within the spreadsheet for the user. The block is as follows:
On clicking the 'Login' button, the user will be logged in, and the existing sheet has to be accessed.
I am not getting the response in my apps script. Can you help, please?
Apologies for any confusion in our previous communications. To clarify, I've been utilizing Firebase for the registration and login functionalities, not Google Sheets. Also, Firebase is the scope of login interface I was required to meet with.
So please can you tell me where I am going wrong in this process of: opening a new sheet for the new user and accessing the existing sheet for the existing user..?
var ss = SpreadsheetApp.getActiveSpreadsheet();
function doPost(e) {
var msg = " ";
if (e.parameter.action == register){
var user = e.parameter.user;
ss.insertSheet(user);
msg = "New User Added";
}
else if (e.parameter.action == login){
var user = e.parameter.user;
ss.getSheetByName(user);
msg = "Sheet accessed";
}
}
no, I'm not logging in.. In the block, I'm trying to access the username entered by the user. 'L-username_txt' means username textbox in the Login Vertical Arrangement..
Here I found the error to be those e.parameter.action values - 'register' & 'login to be in quotes.. now the function is working properly by creating new sheets & accessing them..
But, I have a problem in setting the accessed sheet to be the active sheet in the script. As I have mentioned before, I have other functions like 'Adding User', 'Obtaining User Data and Plotting them' to be executed within the logged in sheet. Passing this ss.setActiveSheet(sheet) in the 'login action' block doesn't solve it either.
You shouldn't or don't want to do that . The username defines the sheet to use, set this as a parameter in your blocks and script to interact with the correct sheet.
I have obtained the username as variable 'user' in the doPost() function. I am not able to pass this local variable in the other functions.
Here I have attached my script. so pls can you look into it? AppsScript.txt (1.7 KB)
I am doing the registering and loging functions in one screen and the adding user data in the next of the app inventor.. does it affect the calling of the function in the script?
Thank you, Tim. With the solution for accessing the user's sheet in place, I've encountered another challenge: encountering the error 'TypeError: Date.toDateString is not a function' . My date is in the format of 'dd-mm-yyyy'.