'How can I get a user's name from their email?

I'm trying to get a user's name from their email and we are all on the same business domain. I saw a post here detailing how to do it if you want to pull from the contacts list. The problem is when I try it myself, it knows that there is contact for me, but it returns all of the values as null. If I use another contact email, then it pulls the info just fine.

The link says that there should be another way to do it but you need admin privileges. I can get that, but all of the links to the usermanager documentation are broken. Also, searching usermanager doesn't come up with anything on Google's developer site.

var email = Session.getActiveUser().getEmail();
Browser.msgBox(email)

var self = ContactsApp.getContact(email);
var name = self.getFullName();


Solution 1:[1]

If parsing from the text, you can use like below,

var email = "[email protected]";
var name   = email.substring(0, email.lastIndexOf("@"));
console.log( name );   // john.doe

Hopefully help

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pathic