So I have a single function that I want to be made available for ALL of my Google Sheets.
It is very simple. Simple enough that I'll post it here in it's entirety.
function swapMonthAndDay() {
// The code below will swap the month and day for any Date objects in the selected cells.
var range = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getActiveRange()
var values = range.getValues();
values.forEach(function(row, y){
row.forEach(function(value, x){
if (value instanceof Date){
var month = value.getMonth() + 1,
day = value.getDate();
value.setMonth(day - 1);
value.setDate(month);
}
});
});
range.setValues(values)
}
I was able to get the result that I want via the "test as add-on..." from the run menu. But this is temporary as the term "test" implies. So, this leads me to believe that I need to publish this as a Sheets add-on. But, I really don't want to publish this to the web store. Too many steps, authentications, certificates etc to get there.
Okay I've finally figured it out.
Turns out, it has nothing to do with the Chrome Web Store. There is the GSuite Marketplace and the old and depreciating Chrome Web store. Currently, the deploy as add-on button links through to the Chrome Web Store deployment flow.
It all relies in the Cloud Project settings.
https://developers.google.com/gsuite/add-ons/how-tos/publish-addons
https://developers.google.com/gsuite/add-ons/how-tos/publish-for-domains
It needs to be accessed via Resources > Cloud Platform project...
, within the menu when editing the script.