migrate google apps script project to new domain - google-apps-script

I've been developing a series of Google App Script projects for a Google Apps for Business client, which are designed to be embedded into their sites pages.
To date, the development and demonstration has been done in my domain (partly because the client would not move their domain to Google unless I could make this bespoke web app work for them).
Now we are at the point we want to transition all of this into their domain.
I guess I could just copy and paste all the files, recreating the projects as I go.
But is there some more elegant way of managing this, eg, to copy the existing projects to the new domain on a project basis?
There's no need to maintain a linkage between the projects in the old domain and the new one, except as a nice to have (so I could keep developing and testing in my domain)

Would just have the client make a copy of your files from their new domain then add you back as an editor. Don't see any reason to copy and paste anything. Since editors can now access the dev link on other's scripts, that may be a reason to not need a library setup. You would just be testing and making changes from their file's script editor from now on.
The owner also has to be the 1st to initially deploy the web app. Have noticed that when you're an deploying subsequent updates as an editor, your domain name still appears in the permissions drop-down on who can access but it does get implemented as theirs.

You could turn your projects into libraries so you don't have two separate instances of the script. Then you could create one MasterScript on their domain that calls the various project scripts: https://developers.google.com/apps-script/guide_libraries

Related

How can I access the files I created in my google project

I have spent a lot of times creating a project in https://console.cloud.google.com, enabling the Drive API, creating server account credentials, and finally writing a small NodeJS integration allowing me to read and write files to Google Drive.
My intent is to be able to store files (organized in folders) on Google Drive from my server, and see them in the classic Google Drive desktop app with my Google account to check everything is fine.
My project seems correctly setup and I was able to create files from my NodeJS program (the files exist, I can list them with the same program), but I can't see the files anywhere in Google Drive with my Google account, with which I created the project.
I was expecting this to be extremely simple. That I would have a out of the box Drive UI allowing me to review the changes.
In the documentation they say I can configure a UI integration but I don't know if this is what I am looking for or not. It seems complicated, talking about my "app" etc, while I just want a simple Google Drive UI for it !
Could anyone help me understand all this ?
Thanks

Cannot find a Google App Script I deployed as a web app

How can I find a Google App Script web app I deployed and modify it? It does not appear in my drive. Perhaps I didn't save it. Does it persist or disappear eventually? Is there somewhere that list all deployed web apps? If so, I have been unable to find it.
If your webapp is recent, simply replace "exec" at the end of the url with "edit" (without quotes) and you'll get the script editor opened on your script.
(Very old webapp have a different structure but it changed quite a long time ago so I guess you're not concerned with that.)
No. There is nothing like deployed webapps list. if u didn't save, u can't get it back even though you had deployed it. Make a try to open that script with the url available in your browser's history.

Testing Google app script HTML interface without deploying app

I am developing a one of those bulk delete script for gmail. I want to create a front end for the script so I can easily modify my settings on a per-label basis to specify how many emails I want to delete during a trigger event and how old they have to be for a particular label. I want to be able to test the interface similar to testing a script.....just hit the run button. However, google's script engine tells me I need to deploy the script and it's HTML files as a web app to test the interface.
Is there anyway to test the the interface and its interaction with my backend google script without deploying as a web app?
The answer is no, unless you "deploy" your code through a Spreadsheet. In fact, it's fairly well-documented.
See Serve HTML as a Google Docs, Sheets, or Forms user interface on that page for a "workaround" to testing your app without actually deploying it.
However, there is no harm in deploying it as a webapp. And as a matter of fact, you can see changes instantly after refreshing your app that you have deployed (published), using the dev macro you're given when you deploy it. This is the most useful tool for UiApp and HTMLService:
Edit: After you're done testing and you've "finalized" your code, you can disable the webapp, meaning that nobody can accidentally access it, you don't post the macro link to it, etc. It's a one-click process. Again, this is really the only way to test the code in my opinion, as it's most succinct for a real "development process". See image below:

How to make a copy of a file between users of different domains?

I would like to make a copy of a Google Spreadsheet file between users that are not on the same domain. The source file has a sharing setting of Anyone with the link can edit.
I created a Web App (with execution permissions set to User accessing the web app) that call an install function:
I was hoping the code would read the source file which is open to everybody and make a local copy to the Google Drive of the user running the Web App (of course assuming the user accept to run the script). The behavior works when it's me running it (because I am the owner of the source) but do not work if the user is from another domain.
Any suggestions on how to achieve this?
function doInstall() {
// The source file is readable by everybody with the link;
var file = DocsList.getFileById('0AlVPTKz1xoevdHc1ZTQ2OGFMXXXXXXXYYYYZZZZ');
file.makeCopy('Test Copy Spreadsheet');
}
I had a different but similar use case and problem. Like you, my source file was accessible to anyone with the link and my domain settings allowed users to share content outside my domain. It worked for me but not for them.
This might work for you, it has for me (so far):
Assuming you have your original script...
Create a separate script for 'Script as web app'.
Write a function (e.g. loadFileIds()) to store the necessary fileIds using ScriptDb. Run the loadFileIds() function.
Write another function (e.g. getFileId()) in the same project that returns your desired file Id from ScriptDb.getMyDb when called. Avoid using DocsList in this function. I originally thought that because getFileId() would 'run as me' that it would be OK but it was always the DocsList line that caused failures when other users triggered the script.
In File > Manage Versions: Save a version of the project.
Under Publish: Deploy that version of your project as a web app. Choose Execute the app as "me(me#mydomain.com)" and set Who has access to the web app to "Anyone".
In your original project go to Manage Resources and enter the Project Key of the web app, choose a version and copy the identifier.
Write a function that calls yourIdentifier.getFileId() and - hopefully - returns the fileId.
In my experience so far external users have been able to access files that they could not when DocsList methods returned null. But there is one more thing to add... You might find you have to share your web app script with your users. I haven't quite made certain that's necessary but I've encountered bugs when I don't. I untick the option to email them the link.
I learned how to do this from examples in the documentation, this video and of course StackOverflow.
As you can see, I'm still working this out myself and testing of the system has so far been just me simulating other users. So no promises. Good luck! I'll star your issue.

Can I copy my Open Graph configuration between apps?

Is there any way to export you open graph settings, or copy them between apps?
We have domain names that we used to deploy our code to before it goes into production.
http://dev-mysite.blah.com
http://int-mysite.blah.com
http://preprod-mysite.blah.com
http://mysite.blah.com
We have setup facebook apps for each of these domain names. And now I need to configure each of these apps to have Open Graph actions and objects. It seems like a pretty common scenario so what do you do?
No, currently you have to do this manually.
However, you can rationalise it down to two app ids - one for production, and the other for all pre-prod and dev environments. This should cut down the work.