Hey everyone, I’m stuck trying to figure out how to test my Google Docs add-on with the new Apps Script editor. The old docs don’t seem to apply anymore and I’m not sure where to start. Here’s what I’ve tried so far:
I looked at a post about Workspace add-ons, but that’s different from what I need.
I know I could just paste my code into a Doc-bound script, but I want to keep it separate.
I’ve set up a GCP project with all the necessary stuff.
I’ve got a simple encryption/decryption add-on working, but I can’t test it properly. Any ideas on how to do this with the new editor? I really want to keep my code in its own project.
Here’s a simplified version of what I’m working with:
function scrambleText(input) {
return input.split('').reverse().join('');
}
function unscrambleDoc() {
var doc = DocumentApp.getActiveDocument();
var content = doc.getBody().getText();
return scrambleText(content);
}
function onOpen() {
DocumentApp.getUi()
.createMenu('Text Scrambler')
.addItem('Unscramble', 'showSidebar')
.addToUi();
}
function showSidebar() {
var html = HtmlService.createHtmlOutputFromFile('sidebar')
.setTitle('Unscrambler');
DocumentApp.getUi().showSidebar(html);
}
hey, i’ve been there too. the new editor can be tricky. have you tried using the ‘Test as add-on’ option? it’s under Deploy > New deployment. super helpful for testing in a real doc without publishing. also, make sure your manifest file has the right scopes. that tripped me up for ages. good luck with your project!
I’ve been through a similar process recently, and I can share what worked for me. First, make sure you’ve enabled the Google Docs API in your GCP project. Then, in the Apps Script editor, go to ‘Settings’ and link your script to the GCP project.
For testing, I found it helpful to use the ‘Test as add-on’ feature. You can access this by clicking on ‘Deploy’ > ‘New deployment’ > ‘Install and test as add-on’. This lets you test your add-on in a real Google Doc environment without publishing it.
One thing to watch out for: make sure your OAuth consent screen is properly configured in the GCP project. I spent hours debugging before realizing this was my issue.
Also, don’t forget to update your manifest file (appsscript.json) to include the necessary scopes and Docs add-on settings. This is crucial for proper functionality.
Lastly, the new editor has improved debugging tools. Use the ‘Debug’ feature to step through your code and identify any issues. It’s been a game-changer for me in troubleshooting complex functions.
Having worked on several Google Docs add-ons, I can offer some insights. The new Apps Script interface does require a different approach. First, ensure you’ve set up proper OAuth scopes in your manifest file. This is crucial for API access.
For testing, I’ve found the ‘Test as add-on’ feature invaluable. It’s under ‘Deploy’ > ‘New deployment’. This allows you to test in a real Doc environment without publishing.
One often overlooked aspect is error logging. Use console.log() liberally in your code. You can view these logs in the Apps Script dashboard under ‘Executions’. This has saved me countless hours of debugging.
Also, consider using the V8 runtime. It offers better performance and more modern JavaScript features. You can enable this in the project settings.
Lastly, don’t underestimate the power of unit testing. Even for small add-ons, it can catch issues early and save time in the long run.