Share resources with new hires

Stay organized with collections Save and categorize content based on your preferences.

Coding level: Beginner
Duration: 20 minutes
Project type: Automation with an event-driven trigger

About this solution

Share resources with incoming employees in one step. This solution uses a form in Google Forms to add new employees to a Google Group. By sharing resources with that group's address, you can easily give new hires access to the resources they need.

If you have permission to add users to a group, you can use this solution to distribute the responsibility to other members of your team. When they submit the form, the event-driven trigger runs the script as you and adds the new person's email to the group.

Optionally, you can enable notifications to get an email every time someone submits the form.

Demo of adding a user to a Google Group from Google Forms

How it works

When someone submits a form with a user's email and the group the user should be added to, the script checks whether or not the person already belongs to that group. If they do, the user receives an email confirming that they're already in the group. Otherwise, the script adds the user to the group and sends them a welcome email.

Apps Script services

This solution uses the following services:

  • Script Service: Creates the trigger that fires the script each time someone submits a form.
  • Groups Service: Checks whether the email submitted on the form is already a member of the group.
  • Advanced Admin SDK Directory Service: Adds the email submitted on the form to the group.
  • Mail Service: Sends an email to the email address submitted on the form to either confirm their group membership or welcome them to the group.
  • Spreadsheet Service: Adds the user's status to the form responses spreadsheet. The status is either Already in group or Newly added.
  • URL Fetch Service: Fetches a Google Docs document as an HTML string. The document contains the content of the email that the script sends.

Before you begin

To use this sample, you need the following prerequisites:

  • A Google Account (Google Workspace accounts might require administrator approval)
  • A web browser with access to the internet

  • You must be a Google Workspace Administrator

Try it

Step 1: Set up the Apps Script project

  1. Click the button below to copy the Share resources with new hires spreadsheet.
    Make a copy
  2. Click Extensions > Apps Script.
  3. At the left, under Services, make sure the AdminDirectory service is listed. If it is, skip to step 6. If it's not, continue to the next step.
  4. Next to Services, click Add a service .
  5. In the dialog, select Admin SDK API and click Add.
  6. In the function dropdown, select installTrigger.
  7. Click Run.

  8. When prompted, authorize the script.

Step 2: Add a user to a group

  1. Return to the spreadsheet and click Tools > Manage form > Go to live form.
  2. Fill out the form with your email address and a group that you have permission to manage the membership for and click Submit.
  3. Return to the spreadsheet and view the form entry. The status column shows whether your email address was added to or already a member of the group.
  4. Check your email for either a welcome email or confirmation of your group membership.

Open the Apps Script project

The sample script's code includes in-line comments to help you understand how it works. To access the code, in the spreadsheet, click Extensions > Apps Script.

Contributors

This sample is maintained by Google with the help of Google Developer Experts.