Google App Script GUI Builder - get project code? - google-apps-script

I've done some searching and i cannot believe that NO ONE has asked this same question, so maybe i'm just not using the right words, but HOW does one get the code from the 'component' (or simply.. the gui) that they just created using the Google App Script GUI Builder? Am i missing something here or is this just plain impossible?

You don't need the code to include a GUI builded Ui in your script - and this code is indeed not available (see Corey's answer here) - but you can modify it or append other elements quite easily as shown in this other post

Related

Transform Old Google Spreadsheet Code

I used this code to insert documents directly into a Google spreadsheet without having to upload files and then create hyperlinks. However, as google moved to the new spreadsheet...
Warning: The UI service was deprecated on December 11, 2014. To create user interfaces, use the HTML service instead.
So know I need help fixing lines like; var app = UiApp.getActiveApplication();
If someone could clarify the different types of programming direction you could take this project from, that would also be very helpful, I am not really sure if I need to work with Javascript or HTML now.
The answer to your question will depend in large part on how you are using UIApp. In most cases it's not as simple as changing a few lines of code but more of a script redesign.
If you are using it to create a custom user interface, your path forward would be to rebuild your interface as HTML/Javascript and serve it to the user with HTMLService. The service is overall much more powerful/flexible and provides a better end-user experience but it means rewriting how your script works. If you want to take a look at a helpful example on how the HTML Service works take a look at the HTML Service Guide or this quick-start example of an add on.
You can still link this html interface with your script using the google.script.run service but you will need to redesign your code/application to work with the new input methods. The good news is although UI service will sunset on June 30, 2015, "Service will no longer appear in autocomplete, although existing scripts should still function."
It's worth considering alternate ways to accomplish the same goal. The best way to do that is to start by asking "What is the intended use of this script? What problem does it solve?" There may be a better way to accomplish that task which may not even involve updating the script.
This is not related to the new spreadsheet version, the message you get is because UiApp has recently been deprecated.
A Google search would have shown you a few tracks to find your way.
One of the best I found is this one from Sandy Good : Google apps script UI services to HTML services
It shows a typical example of conversion to HTMLService.

Is there a way to make my standalone script, bound to a doc?

What I would like to achieve is bounding my standalone script to one of my Google Docs.
The resource available at developers.google.com haven't helped me in this instance. However these are the links related to this topic:
https://developers.google.com/apps-script/guides/bound
https://developers.google.com/apps-script/guides/standalone
I suspect 'No'.
At this current time I am only playing around using this api.
The answer is; there is no way you can achieve a simple import form standalone to bound.
But
There are several work arounds, such as copying the code from the standalone to the bound one. Or via import methods mention by #Sandy Good
Thanks to all that helped.

Is there a way of seeing the script code for an action I have performed?

I am new to writing scripts in Google Apps. I am trying to script various actions in Google Docs which previously I would have done through the main user interface. Is there a way of "recording" such actions as they are carried out, analogous to recording a Macro in Excel?
For example, I am creating a Form in Google Docs. Using the main interface, I can add an Image item and upload an image from another source (Google Drive, my desktop, etc.), but I can't work out the script code that would perform this same action. Is there any way to output the script that would have carried out the same action that I have just performed?
Many thanks.
Currently, you cannot 'record' a macro.
There is an issue in the Issue tracker (issue 650) where Google have mentioned that it is not feasible at the moment (Jul 2010). You may star the issue to register your interest to the enhancement request.
I think the real issue is that the GApps scripting functions are manipulations of the underlying object model of the document. The UI also manipulates the underlying object model, but no one has yet created the functions to emulate the UI in GApps script form. Recording the actions would then be a separate step and converting the recorded actions into GApps functions would be yet another step.
So you need to be clear: is your goal to be able to record and play back UI actions, or is your goal to be able to upload an image into a GDoc? You asked about recording and that's the answer you got. Maybe if you asked about how to use GApps to add an image to a GDoc, you would get a more useful answer.
My own personal question would be:
I haven't figured out how to use the GApps documentation very
efficiently yet. I do a lot of fruitless hunting. How do I find in the
docs how to add an image to a GDoc?
I hope this helps.

Get text of php file without executing it - using GAS urlfetch()

I'm using a general Google Apps Script function to be able to read, prettify and publish Google Apps Script code and data from a scriptdb. I've recently extended it to publish code from a Gist or from a given web address. The purpose it to be able to include live code snippets in documentation. I have it all working fine for most use cases, including for html and other server based files.
However, php files get executed rather (than returned as text/html) when accessed with urlFetch(). I know it's along shot, but does anyone know of any header options, or indeed any other technique, I can use to generally override this?
What you are asking for would be a major security problem. It is not possible to ask for the php-code instead of the result of the php script execution. Well, not exactly - it is up to the Server hosting that php script what it does with it. If there was no php extension installed on the server it would return the php code or the file as whole.
But to help with your request:
You should ask the server administrator / website owner if the code is available somewhere and if so what the url is. I believe there is a php extension that allows files to be looked at with colors, text indent and everything - but i think it is disabled by default (or you need to rename your php file to something else)

GUI components not submitted when publishing to gallery: Google App Script

When I published an app to the google app script gallery for spreadsheet tools, it failed to upload the GUI builder components as well. Do you know how I should go about remedying this?
I just get this:
Invalid argument: resourceName (line 37)
When trying to execute the code. Line 37 corresponds to where the code exists which loads the GUI builder component in to the UI app. I was going to rewrite the code and programmatically create the visual elements, but it seems like that would defeat the purpose!
Many thanks,
Eamonn
You're right, the GUI Builder falls short when you try to share it. Being through the Script Gallery or as a library. There's no way at all to export it and import in another script.
And that the reason why I never use it. Sometimes I play with it just to make fast mock ups to see if how an idea will actually look on Apps Script, but never as the real thing I'm going to develop.
You should open an issue report on the tracker, since publishing on the Gallery should really work out-of-the-box.