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!
After going through the documentation here it states:
"... relations: A list of the user's relationships to other users..."
As for relation value types:
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.
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: