Google app script - search hosted attachments - google-apps-script

How to search for hosted attachments in google sites using Google App script?
I tried to search using page.search("query", options) with page type as Webpage, Filecabinetpage, but I'm not able to search my page attachments.
Can anybody help me in this?

There is no direct search method. However, you can use the Page.getAttachments() to get a list of attachments and do a manual search through them.
You can open a request in the Issue tracker for this feature to be added.

Related

How to embed a web app created using Apps script in data studio?

I created a simple calculator using Google Apps Script and deployed as web app. The calculator has four inputs and the calculated value is generated with a formula.
But I need that in data studio. So I used the "URL embed" feature in data studio. But it displays a message saying "can't embed due to provider site restrictions".
Both apps script and data studio are services provided by google. But I don't understand why I can't embed a website created using apps script into data studio.
I have deployed the web app in every possible way but did not work.
Is there any way to embed a website into data studio?
If not possible using apps script, then which other programming language should I use to create a calculator and embed it into google data studio?
Any help will be appreciated. Thanks in advance.
As you can check in DataStudio documentation, not all sites can be embeded and this resource can be blocked by the website owner:
This is related with X-Frame-Options in the HTTP header. (Documentation)
This answer has more additional information of this option:
how to block website from loading in iframe?
So I guess Google Apps Script is sending and X-Frame-Options=DENY or something that avoid it from being load in an <iframe>.
I searched a little, and I found this answer. I'm not a Google Apps Script expert, but apparently, Google Apps Script already has this feature, but you need to enable it.
Embedding Google Apps Script in an iFrame

Google App Script published as a web app not working?

I have currently a simple Hello World Google App Script following Google Documentation
I published it, giving access to anyone on the internet (including anonymous users) and then get both a xxx/dev and xxx/exec urls (latter for "published versions" usage, latter for work in progress usage).
None of those URL are currently working when I call it in my Browser (or through a cURL command) :
Any idea on what could go wrong ?
Note : I already published some Google App Scripts in the past and they are still working today. It is as if my "new" google app scripts was not getting published.
This could be because you are logged into multiple Google accounts. Try:
deleting the "u/0" from the URL
signing out of all of your Google accounts, and back into just one
trying the /exec in an "incognito" window

How to make starting a UiApp by a group of users easy?

After opening Gmail or Google Drive you see the google bar (containing the Google logo, a searchbox and clickable button for apps, notification of unread messages, sharing and about) on top of the window.
I want to put a put a button for starting my UiApp (build with GAS) there as well.
Is this possible (and how) ?
Several users will have read access to the google drive. I want those users to be able to start my UiApp from a button in google bar as well. What should I do (and what should they do) to make that possible?
If this is not possible, where can I put my UiApp best so users can start it easy?
My application is NOT intended to be accessible by other people except the ones I provided access to my Google Drive.
I believe you can accomplish this by leveraging the Gadgets section of the Gmail API to accomplish this as detailed here. I've seen this type of Gadget added by a Chrome Extension before but not directly from Google Apps Script.
I think you would need to use the "New" button, and publish a script to the Chrome Web Store. Then your app would be in the drop down list of the "New" button. The problem with that, is that the general public could see the app. I'm assuming you don't want that.
If you want an easily accessible central location for users, you could create a website with Google App Engine. You can get a free domain name of
www.mySiteName.appspot.com
It would be easier for users to get there than the URL of your Apps Script.

import google analytics report in html page

I am having a requirement of showing google analytics report in the HTML page.I mean without login into Google Analytics , I have to show the report directly into the webpage.Is it possible ,kindly let me know how to do it.
Option 1:
Do some serverside scripting with your favourite programming language to draw data from the Google Analytics reporting API (https://developers.google.com/analytics/devguides/reporting/)
Option2:
Use Google Apps Script to pull data from you GA account. Create a graph from the data. Embed graph in Google Sites webpage. Embed Google Sites page in your site via iframe
Option3
Use Google Apps Script to pull data from you GA account. Create Json/XML-Feed via Apps Script. Pull Feed from Apps Script and parse it into your site via Javascript.
So it's doable (but not via Javascript alone without your visitors logging in to the GA Account in the Browser) but requires more programming than conveniently can be explained in a stackoverflow answer - maybe you could explore one of the options and then come back for specifics.

Google docs api file view and download

Has anyone had any luck with the downloading of files using the google docs api?
I've been struggling for weeks now to get this working with no success.
https://developers.google.com/google-apps/documents-list/#downloading_documents_and_files
I can get the list of files successfully and display within my web page. However what i want to do next is allow the user to click on a file link which will then open it up in a google docs viewer allowing them to then view and edit that file.
Please advice.
I'd recommend using the newer Google Drive API which is easier to use, supports multiple programming languages and has documentation for each method, including downloading files:
https://developers.google.com/drive/manage-downloads