1

I am trying to create a user from Google Forms and via App Script, the account will be provisioned in GSuite. When running the script, the account gets created but the employee and organization details are not included in the user account details.

var user = {
  primaryEmail: preferredEmail,
  name: {
     givenName: firstName,
     familyName: lastName,
     fullName: firstName + ' ' + lastName,
     },
  relations: {
     value: reportingManager,
     type: 'Manager',
    },
  organizations: {
     title: designation,
     primary: true,
     department: dept,
     description: employmentType,
     costCenter: location,
    },

  password: password,
  changePasswordAtNextLogin: 'true',
};

user = AdminDirectory.Users.insert(user);
Logger.log('User %s created with ID %s.', user.primaryEmail, user.id); 

1 Answer 1

1

I tested out again by adding [] and it worked.

var user = {
  primaryEmail: preferredEmail,
  name: {
     givenName: firstName,
     familyName: lastName,
     fullName: firstName + ' ' + lastName,
     },
  relations: [{
     value: reportingManager,
     type: 'manager',
    }],
  organizations: [{
     title: designation,
     primary: true,
     department: dept,
     description: employmentType,
     costCenter: location,
    }],

  password: password,
  changePasswordAtNextLogin: 'true',
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.