Google Sheets script: swap URLs - google-apps-script

I have a Google Sheet that links out to several areas in another app. I was informed that the app is going to have its URL changed, and I was wondering if there's a way to script something to easily update the links in my sheet.
While the domain of the URL will be changing, the trailing information will remain the same. Here's an example:
Current URL structure
currenturl.app.com/folder/item.html
New URL structure
newurl.app.com/folder/item.html
Is there a way that I can just search my file for currenturl.app.com and change that to newurl.app.com, and leave the /folder/item.html in place using a Google script?
Any help would be greatly appreciated, manually updating each link is going to take forever!
Thank you :)

You don't need Apps Script for this. Just use Find & Replace

Related

Script to get a GooglePhoto using filename stored in GoogleSheets

I have a Googlesheets that has in one of its columns the filename (as "filename.jpg") of pictures stored in GooglePhotos (and/or Google Drive). I would like to have a script that would show me the selected picture when I click on a given cell of that particular column.
I'm quite familiar with Googlesheets Scripts and have looked at Google Photos API but don't know where to start.
Has anyone developed something like this and is willing to share? Any hints will be very much appreciated.
Many thanks in advance
I have a similar solution. You have to start from Browser API and this existing repo https://github.com/gsuitedevs/apps-script-samples/tree/master/docs/dialog2sidebar
But before that you have to realize the next flow:
Get a string
Try to search the file with this string
Return the file or undefined

How to send data from a web form to a Google Sheet

OK, I was following this web page for instructions https://codeburst.io/avoid-databases-by-hacking-a-google-form-d20cd2b6a020
For the most part, everything works except the script. What is happening is that sometime after he wrote these instructions Google changed the way it posts to the spreadsheet.
If I do the initial part of this and strip out all the formatting from the source HTML, I can put the form in a web page, if I add the script so that it does not show Googles response to updating the spreadsheet, it will not update the spreadsheet.
What I am looking for is if anyone knows what response Google is looking for to do the update to the spreadsheet, I am thinking that there must be some sort of security protocol that is keeping this from working. The form I built is only for collecting an email address, so any help would be greatly appreciated.
All the code for the script is in the link, I have not altered it in any way, so if you want to try it out, just follow the instructions on the page. I would post my code, but then I open my spreadsheet to the world and at this point, I am not ready for that.

Do Google Apps Scripts have a Copy URL?

I'm wondering if there is a way to share a link to a Google Apps Script file that forces users to make a copy of it? Using Google Docs, you can append /copy to the url. For example:
https://docs.google.com/document/d/19yoQ71RcqNsYgPmZHzw96G_QH05hC20sWxk_ktahpXY/copy
This will force users to make a copy of the original document. I've been trying to do something similiar with a Google Apps Script file.
I've tried appending copy to the URL like this but it doesn't seem to work. As a potential work around, I could just use embedded scripts and share the Sheet/Doc/Form.
Anyone know of a URL parameter to force copying of a Google Apps Script file?
You can use this format to quickly make a copy of any public Google Script.
https://script.google.com/d/SCRIPT_ID/edit?newcopy=true
See example.
There is no way to do this since the new editor has been rolled, have reported it on this issue:
https://issuetracker.google.com/issues/198266388
You can manually make a copy on the new editor by going to the "Overview" tab, and on the top-right is the button to make a copy.

Uploading an XLSX converting and replacing a current spreadsheet

Just a general question, I would like to create a user upload form that would convert an .xlsx to the corresponding Google Sheets version and then replace a currently existing sheet on my drive. The main question and aspect that I'm not sure is achievable is replacing a current google sheet. Is a project like this even achievable in a reasonable manner? The reason I want to replace it is because the KeyID for that sheet is used in a couple other app scripts for a website. Thanks for the suggestions and advice.
Yes, this is possible. About being "reasonable", well... I think it is, it's not a single line script, but this is not the most simple task either.
But from what I understood from your use-case (other app script for a website), I think it's better if you enhance your other scripts to either look for the newest sheet on a given folder or fetch the ID from somewhere that you can update from the "form upload" script. Also, by doing this, you'll avoid getting inconsistent data in the middle of an update.

Use a Google Docs Spreadsheet as a datasource for a dynamic Google Sites webpage

I have a Google Form that feeds a Google Docs Spreadsheet. I'd like to--in turn--have that Google Docs Spreadsheet feed a webpage.
In plainer English, babysitters fill out the form to sign up to be in our community's Babysitter Directory. The spreadsheet houses all of the data. I'd like to code a webpage to pull selected bits of the data for the online directory.
I've tried doing a separate sheet in the spreadsheet, using a QUERY to select the columns that I want to include (and the order in which I want to include them), publishing that sheet to the web, then embedding that sheet into the webpage in an iFrame. And that works.
But even with the QUERY, there are SO many columns that users need to scroll WAY over to the right to see all the data for each babysitter. It's unwieldy.
What would be way better would be if I could break the data for each entry over multiple lines and do some nice formatting for a directory, rather than just a linear spreadsheet. So that, essentially, each babysitter's "entry" in the directory is more than 1 line long. Does that make sense?
If I was working in Office, I would know exactly what to do: use the Excel spreadsheet as the datasource for a Word Mail Merge and I would put move the fields around on the page to make it all look good.
And, to be sure, if I can do this in a Google Doc, then embed the Doc into the webpage, that's fine, too. But I would think there's some way I can do it directly in the Google Site?
Can I?
If anybody has even just a reference page for me to take a look at, I'd appreciate it.
Thanks!
Are you trying to do this in Google Sites? If so, you can embed the entire spreadsheet on the page, but if you only want certain columns, you can try inserting an Apps Script widget on the page.
You need to know how to write a Google Apps Script that will run JS functions and render HTML, here is a tutorial
To create the Script that can run on your page, go to:
More > Manage site > Apps Script > Add new script
Here's also a link to how to interact with Spreadsheet data.
What you want to do is more or less a database interface that uses a spreadsheet as 'data holder', depending on your programming skills it can be quite easy or very hard...
Here is an example of such a webapp, its has probably too many fields and features but the general idea is the same (a quick search tool and a window to show results).
It that what you had in mind ?
If so I can share the code to help you to get started but if you are not familiar with javascript it will probably need too much effort to get through.