#How to Migrate the Primary Domain of a Google Apps Account
##Instructions
###Step 1
Log into the administrator account. If you're reading this, that's probably your account.
###Step 2
Read the Google Apps Script Quickstart Guide to understand the basic concept behind using Google Apps Scripts within Drive.
Be sure to pay special attention to Step 2: Turn on the Directory API--because the migration script requires it.
###Step 3
Copy the code from Migration.js
, and place it within a Google Apps Script of your very own.
###Step 4
Create a function like:
function migrateMe() {
// call migrateDomain() with your organization and desired domain here
}
"Why is the organization name parameter necessary?" you may ask? Well, it's because without it,
I was getting some weird error about an invalid firm_name
or something. Just make sure that
you provide a non-null-nor-empty-string value for that parameter.
###Step 5
Be sure that your 'migrateMe' method is selected in the drop-down next to the run and debug buttons at the top of the script editor, and then press that run button.
You can see whether or not the migration was a success by looking at the logs, which can be found from within the View menu.
If the migration failed, you can always resort to sprinkling Logger.log('%s', ...);
throughout the code to follow the different customer values being sent and received.
##How I Figured This Out
Lots. Of. Googling.
Below are what I believe to be the best resources for reverse engineering my instructions for yourself, listed in the order I think best to read.
- Google Apps Administrator's page on how change your primary domain, for all the risks and alternatives.
- Google Developers' page on Google Apps Scripts and how they do, for getting a grip on what a Google Apps Script even is in the first place. Special shoutout to Step 2! Thanks for telling me how to enable those APIs, buddy.
- Google Developers' page on how method signatures are determined for Google services based on their HTTP interfaces. Without this page, I would have never figured out which methods to call on which objects when. Even then I still struggled—but I survived!
- And last but not least, Google Developers' page on the Directory API's HTTP interface and how to use it to change your primary domain.