The following Google Apps Script is designed to automate the assigning of a Google Workspace (e.g. Education Plus) licence in the Google Admin Console, for individual accounts/users by providing them with a quick Google Form to submit.
This saves having to manually go into the Google Admin Console and assign a licence. All the user has to do is tick the box on the Google Form, they will receive an automated confirmation email and their new licence will be applied within 24 hours.
You can refer to the Google product and SKU IDs webpage if you need to assign a different licence type. There is some basic checking to see if an account/user is an 'Administrator' and it will therefore prevent them from getting a licence.
Screenshot of the Google Form title used for submission |
The Code
You will need to make sure you have enabled the below Advanced Google services in the Script Editor:
- AdminLicenseManager - V1
- AdminDirectory - directory_v1
You will also need to make sure you create the 'onFormSubmit' Trigger so that the code runs each time the Google Form is submitted.
One of the checks is to see if a user is an Administrator, as in this example we do not want them to be able to automatically upgrade:
var userDetails = AdminDirectory.Users.get(emailAddress);
Assuming they are not then we can proceed with trying to assign a new licence:
var results = AdminLicenseManager.LicenseAssignments.insert({ userId: emailAddress },productId,skuId);
Should there be an issue, such as the user already having an Education Plus licence, then we Catch this and filter the error message, along with sending them a customised email.
Download
Automate the Google Education Plus upgrade for individuals folder download (please use 'File' > 'Make a copy' for your own version).
No comments:
Post a Comment