I am making a Google apps script on a spreadsheet that creates users on a domain submitted from a registeration form powered by Google forms, creating a user was easy using this method UserManager.createUser(username, firstname, lastname,password);
but the problem that I'm facing is how to check if the user being inserted into the spreadsheet already exists.
I checked over the internet specially at https://developers.google.com/apps-script/ but found nothing helpful.
What about using a try catch block? Simple but should facilitate your need.
try{
// Get an existing user
var user = UserManager.getUser("delete.me");
}catch(e){
// If user does not exist // i.e. error // create the user
var newUser = UserManager.createUser('delete.me', 'Delete', 'Me', 'testing123');
}