Berbagi fasilitas dengan karyawan baru
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Tingkat coding: Pemula
Durasi: 20 menit
Jenis project: Otomatisasi dengan pemicu berbasis peristiwa
Tujuan
- Pahami fungsi solusi.
- Pahami fungsi layanan Apps Script dalam solusi.
- Siapkan skrip.
- Jalankan skrip.
Tentang solusi ini
Penting: Anda harus menjadi Administrator Google Workspace untuk menggunakan solusi ini.
Bagikan referensi kepada karyawan baru dalam satu langkah. Solusi ini menggunakan formulir di Google Formulir untuk menambahkan karyawan baru ke grup di Google Grup. Dengan membagikan
sumber daya ke alamat grup tersebut, Anda dapat dengan mudah memberi karyawan baru akses ke
sumber daya yang mereka butuhkan.
Jika memiliki izin untuk menambahkan pengguna ke grup, Anda dapat menggunakan solusi ini untuk mendistribusikan tanggung jawab kepada anggota tim lainnya. Saat mereka mengirimkan
formulir, pemicu berbasis peristiwa menjalankan skrip sebagai Anda dan menambahkan email orang
baru ke grup.
Secara opsional, Anda dapat mengaktifkan notifikasi untuk mendapatkan email setiap kali seseorang mengirimkan formulir.

Cara kerjanya
Saat seseorang mengirimkan formulir dengan email pengguna dan grup yang harus ditambahkan pengguna, skrip akan memeriksa apakah orang tersebut sudah tergabung dalam grup tersebut atau belum. Jika sudah, pengguna akan menerima email yang mengonfirmasi bahwa dia sudah tergabung dalam grup. Jika tidak, skrip akan menambahkan pengguna ke grup dan mengirimkan email selamat datang kepada pengguna tersebut.
Layanan Apps Script
Solusi ini menggunakan layanan berikut:
- Layanan skrip–Membuat pemicu yang
menjalankan skrip setiap kali seseorang mengirimkan formulir.
- Layanan grup–Memeriksa apakah email yang dikirimkan di formulir sudah menjadi anggota grup.
- Layanan lanjutan Direktori Admin SDK–Menambahkan email yang dikirimkan pada formulir ke grup.
- Layanan email–Mengirim email ke alamat email yang dikirimkan di formulir untuk mengonfirmasi keanggotaan grup atau menyambut anggota baru ke grup.
- Layanan Spreadsheet–Menambahkan status pengguna ke spreadsheet respons formulir. Statusnya adalah Sudah ada di grup atau Baru ditambahkan.
- Layanan Pengambilan URL–Mengambil dokumen Google Dokumen sebagai string HTML. Dokumen berisi konten email yang dikirim skrip.
Prasyarat
Menyiapkan skrip
Klik tombol berikut untuk menyalin spreadsheet Bagikan sumber daya dengan karyawan baru. Project Apps Script untuk solusi ini dilampirkan ke spreadsheet.
Buat salinan
Klik Ekstensi > Apps Script.
Di bagian Layanan, pastikan layanan AdminDirectory tercantum. Jika ya, langsung ke langkah 6. Jika tidak, lanjutkan ke langkah berikutnya.
Di samping Layanan, klik Tambahkan layanan add.
Di dialog, pilih Admin SDK API, lalu klik Tambahkan.
Di dropdown fungsi, pilih installTrigger.
Klik Run.
Saat diminta, izinkan skrip.
Jika layar izin OAuth menampilkan peringatan Aplikasi ini belum diverifikasi,
lanjutkan dengan memilih Lanjutan >
Buka {Project Name} (tidak aman).
Penting: Jika Anda menjalankan fungsi ini lebih dari sekali, beberapa pemicu akan dibuat dan email duplikat akan dikirim. Untuk menghapus pemicu tambahan, lakukan
langkah-langkah berikut:
- Klik Pemicu
.
- Di samping pemicu, klik Lainnya
> Hapus pemicu.
Jalankan skrip:
- Kembali ke spreadsheet dan klik Alat
> Kelola formulir
> Buka formulir aktif.
- Isi formulir dengan alamat email Anda dan grup yang izin keanggotaannya dapat Anda kelola, lalu klik Kirim.
- Kembali ke spreadsheet dan lihat entri formulir. Kolom status menunjukkan apakah alamat email Anda ditambahkan ke atau sudah menjadi anggota grup.
- Periksa email Anda untuk menemukan email sambutan atau konfirmasi keanggotaan grup Anda.
Kontributor
Contoh ini dikelola oleh Google dengan bantuan Pakar Developer Google.
Langkah berikutnya
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-31 UTC.
[null,null,["Terakhir diperbarui pada 2025-08-31 UTC."],[[["\u003cp\u003eThis solution allows Google Workspace administrators to easily share resources with new employees by automatically adding them to a Google Group.\u003c/p\u003e\n"],["\u003cp\u003eThe script uses an event-driven trigger to add new employees to a group when their information is submitted via a Google Form.\u003c/p\u003e\n"],["\u003cp\u003eThe script utilizes various Apps Script services including Groups, Admin SDK Directory, Mail, and Spreadsheet to manage group memberships and communicate with users.\u003c/p\u003e\n"],["\u003cp\u003eSetup requires copying a spreadsheet, enabling the AdminDirectory service, and authorizing the script to run.\u003c/p\u003e\n"],["\u003cp\u003eRunning the script involves submitting a form with the new employee's email and desired group, triggering the automatic addition and email notifications.\u003c/p\u003e\n"]]],["This solution automates sharing resources with new hires using Google Workspace. It utilizes a Google Form submission to trigger a script that adds new employees to a specified Google Group. The script checks for existing membership, adds the user if necessary, and sends either a welcome or confirmation email. It leverages Apps Script services, including Script, Groups, Admin SDK Directory, Mail, Spreadsheet, and URL Fetch to manage triggers, check group membership, add users, send emails, and update form response spreadsheet with user status.\n"],null,["# Share resources with new hires\n\n**Coding level** : Beginner \n\n**Duration** : 20 minutes \n\n**Project type** : Automation with an [event-driven trigger](/apps-script/guides/triggers/installable#event-driven_triggers)\n\nObjectives\n----------\n\n- Understand what the solution does.\n- Understand what the Apps Script services do within the solution.\n- Set up the script.\n- Run the script.\n\nAbout this solution\n-------------------\n\n**Important**: You must be a Google Workspace Administrator to use this\nsolution.\n\nShare resources with incoming employees in one step. This solution uses a form\nin Google Forms to add new employees to a group in Google Groups. By sharing\nresources with that group's address, you can easily give new hires access to the\nresources they need.\n\nIf you have permission to add users to a group, you can use this solution to\ndistribute the responsibility to other members of your team. When they submit\nthe form, the event-driven trigger runs the script as you and adds the new\nperson's email to the group.\n\nOptionally, you can turn on notifications to [get an email every time someone\nsubmits the form](https://support.google.com/a/users/answer/9308874).\n\n### How it works\n\nWhen someone submits a form with a user's email and the group the user should be\nadded to, the script checks whether or not the person already belongs to that\ngroup. If they do, the user receives an email confirming that they're already in\nthe group. Otherwise, the script adds the user to the group and sends them a\nwelcome email.\n\n### Apps Script services\n\nThis solution uses the following services:\n\n- [Script service](/apps-script/reference/script)--Creates the trigger that fires the script each time someone submits a form.\n- [Groups service](/apps-script/reference/groups)--Checks whether the email submitted on the form is already a member of the group.\n- [Admin SDK Directory advanced service](/apps-script/advanced/admin-sdk-directory)--Adds the email submitted on the form to the group.\n- [Mail service](/apps-script/reference/mail)--Sends an email to the email address submitted on the form to either confirm their group membership or welcome them to the group.\n- [Spreadsheet service](/apps-script/reference/spreadsheet)--Adds the user's status to the form responses spreadsheet. The status is either **Already in\n group** or **Newly added**.\n- [URL Fetch service](/apps-script/reference/url-fetch)--Fetches a Google Docs document as an HTML string. The document contains the content of the email that the script sends.\n\nPrerequisites\n-------------\n\n- A [Google Workspace account](https://workspace.google.com/features/)\n- You must be a Google Workspace Administrator\n\nSet up the script\n-----------------\n\n1. Click the following button to copy the **Share resources with new hires**\n spreadsheet. The Apps Script\n project for this solution is attached to the spreadsheet.\n\n [Make a copy](https://docs.google.com/spreadsheets/d/1IK9nIanIOxInnvUtaY9lsXHAqokkA9xqcC43VRxQ-fo/copy?usp=sharing)\n\n2. Click **Extensions** \\\u003e **Apps Script**.\n\n3. Under **Services** , make sure the **AdminDirectory** service is\n listed. If it is, skip to step 6. If it's not, continue to the next step.\n\n4. Next to **Services** , click Add a service add.\n\n5. In the dialog, select **Admin SDK API** and click **Add**.\n\n6. In the function dropdown, select **installTrigger**.\n\n7. Click **Run**.\n\n8. When prompted, authorize the script.\n If the OAuth consent screen displays the warning, **This app isn't verified** ,\n continue by selecting **Advanced** \\\u003e\n **Go to {Project Name} (unsafe)**.\n\n**Important**: If you run this function more than once, it generates multiple\ntriggers and will send duplicate emails. To delete extra triggers, take the\nfollowing steps:\n\n1. Click **Triggers** .\n2. Next to the trigger, click More \\\u003e **Delete trigger**.\n\nRun the script\n--------------\n\n1. Return to the spreadsheet and click **Tools** \\\u003e **Manage form** \\\u003e **Go to live form**.\n2. Fill out the form with your email address and a group that you have permission to manage the membership for and click **Submit**.\n3. 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.\n4. Check your email for either a welcome email or confirmation of your group membership.\n\nContributors\n------------\n\nThis sample is maintained by Google with the help of Google Developer Experts.\n\nNext steps\n----------\n\n- [Event-driven triggers](/apps-script/guides/triggers/installable#event-driven_triggers)\n- [Extend Google Sheets](/apps-script/guides/sheets)"]]