Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

228
Visualizações
How to add multiple user attributes in app-script?

I am automating the onboarding process in our organization and have a google form connected with app-script. The user is getting created in google admin but I would like to add more attributes such as Manager's name, Department, phone number etc.

Here is the API method:

var user = {
  "primaryEmail": email,
  "name": {
    "givenName": givenName,
    "familyName": familyName
  },
  "relations": [{
    "value": manager,
    "type": manager,
  }],
  "password": password,
};

console.log(password);

try {
  user = AdminDirectory.Users.insert(user);
  console.log('User %s created with ID %s.', user.primaryEmail, user.id);
} catch (err) {
  console.log('Failed with error %s', err.message);
}

But as of now, there is something wrong with the manager code because I get the following error:

Failed with error API call to directory.users.insert failed with error: Invalid value for: TEST is not a valid value

(For context, I had put in TEST as the manager's value in the form)

Please let me know what I am doing wrong so I can fix this. Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

After going through the documentation here it states:

"... relations: A list of the user's relationships to other users..."

As for relation value types:

  1. type accepts values:

    admin_assistant, assistant, brother, child, custom, domestic_partner, dotted_line_manager, exec_assistant, father, friend, manager, mother, parent, partner, referred_by, relative, sister, spouse

Custom: Let's you add custom values.

  1. values refer to the person the user is related to. It can be a name or an email address as seen below.

In the onboarding scenario, this can be implemented to specify the manager's email address for this user:

let email = 'GIMMEABREAK@domain.xyz'
let givenName = 'X'
let familyName = 'testOnly'
let password = 'passowerd#$"#$22'


let type = 'manager'
let value = 'yancymelany@domain.xyz'

var user = {
  "primaryEmail": email,
  "name": {
    "givenName": givenName,
    "familyName": familyName
  },
  "relations": [{
    "value": value,
    "type": type,
  }],
  "password": password,
};

And this succeeds:

enter image description here

enter image description here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda