To start off I would like to say I am nowhere near a knowledgeable person in coding and I just happen to be the person with most knowledge regarding this subject hence the reason why I get to look for help.
A while back I Frankensteined together a google script to put a time stamp on a page that would show last revision date and published date. However, recently I've noticed a "Deprecated" message on two lines. I struggled quite a bit to make the current script work so I'm here for some guidance.
function doGet(e){
var app= UiApp.createApplication();
var page = SitesApp.getActivePage();
var updated = Utilities.formatDate(page.getLastUpdated(), "America/Chicago", "EEE, d MMM yyyy, hh:mm:ss a '('z')'");
var published = Utilities.formatDate(page.getDatePublished(), "America/Chicago", "EEE, d MMM yyyy, hh:mm:ss a '('z')'");
app.add(app.createHTML('Last revision: ' + updated));
app.add(app.createHTML('Published: ' + published));
return app;
}
This is the current code and here is the error message I'm getting
UiApp API is deprecated.
File: Code Line: 2
The API has been marked as deprecated which means that the feature should be avoided and may be removed in the future. Consider using an alternative solution.UiInstance API is deprecated.
File: Code Line: 6
The API has been marked as deprecated which means that the feature should be avoided and may be removed in the future. Consider using an alternative solution.
Any help or guidance would be greatly appreciated. I will keep on doing some research on my side to hopefully better understand this deprecated APIs
After some perusing of https://developers.google.com/apps-script/reference/ui/ui-instance and https://developers.google.com/apps-script/reference/html/html-service it would seem like this is the way to do it. This is untested code.
function doGet(e){
var app= HtmlService.createHtmlOutput();
var page = SitesApp.getActivePage();
var updated = Utilities.formatDate(page.getLastUpdated(), "America/Chicago", "EEE, d MMM yyyy, hh:mm:ss a '('z')'");
var published = Utilities.formatDate(page.getDatePublished(), "America/Chicago", "EEE, d MMM yyyy, hh:mm:ss a '('z')'");
app.append('Last revision: ' + updated);
app.append('Published: ' + published);
return app;
}