Reputation: 23
I'm running multiple codes with different domains. I do not want to put the domain manually.
For example:
var domainName = 'domain.com.br';
I would like to know if it is possible to get the domain (G Suite) through a variable.
For example:
var domainName = get.domain ();
Upvotes: 0
Views: 172
Reputation: 38424
Use Session.getActiveUser().getEmail()
/ Session.getEffectiveUser().getEmail()
to get the active/effective user email address and JavaScript string handling techniques like using regular expressions:
var domain = Session.getActiveUser().getEmail().match('\@(.*)$')[1]
Validation of regex expression
var match = '[email protected]'.match('\@(.*)$');
console.info(match[1])
Upvotes: 1