Google Apps Script To Help Error When Embedding Go

2019-04-13 04:48发布

Spreadsheet A is the master data source for the group that welcomes Newcomers to our little town. It has a ton of very sensitive data in it and cannot be public, not even a little bit. (We're talking about names and birth dates of kids and where they go to school . . . keeping Spreadsheet A secure is mission critical.)

So, Spreadsheet B uses an importRange and a query to pull the necessary columns from Spreadsheet A to populate our "Member Directory".

Then, I embedded Spreadsheet B in the group's Google Site. (Feel free to check out the site if you like at www.SewickleyNewcomers.com )

And it works beautifully.

BUT . . . after I shut Spreadsheets A & B down and a few hours go by, if I try to open the webpage that has the Member Directory embedded in it, the embedded sheet says "#VALUE!"

When I then go and open Spreadsheet B again, it says the same thing: "#VALUE!".

UNTIL, I let Spreadsheet B sit for a few minutes. Then, after it's sat for a few minutes, all of a sudden, all of the data populates again.

AND if I go back to the webpage with the Member Directory embedded in it, all's good.

Presumably, the problem is that if Spreadsheet B is not open, it can't pull the data from Spreadsheet A.

But I can't embed Spreadsheet A because there are columns and sheets that cannot be publicly accessible, as mentioned above.

Some details:

  • Both Spreadsheet A and Spreadsheet B are currently set to "Anyone with the link" as the sharing preference. (Although I'd ideally like to get Spreadsheet A back to "Private".)

  • Spreadsheet B is embedded in the Google Site with the built-in Insert Spreadsheet Widget.

  • Here's the formula I'm currently using to pull the data from Spreadsheet A to Spreadsheet B:

    =arrayformula(query(importrange("_","Master!A:Z"), "select Col3, Col2, Col22, Col18, Col19, Col20, Col21, Col24 where Col26='Yes, go ahead and include my contact information in the online directory and in the print directory.' and (Col4='Yes' or Col4='yes') order by Col3"))

Anybody have any thoughts about what's going on here? And ideas for other ways I can get the necessary data out of Spreadsheet A and onto the site (I certainly don't have to go through Spreadsheet B, I just couldn't think of another way to keep all the other data on Spreadsheet A private)? Is there a solution that uses some kind of Apps Script on the Google Site to end-run needing to embed the spreadsheet?

Thanks in advance! And all the people who move to Sewickley thank you, too!

1条回答
闹够了就滚
2楼-- · 2019-04-13 05:25

importRange shows what it is expected to show 85% of the time (according to my experiments). During the other 15%, it shows #N/A or #VALUE.

I believe that if, having found #VALUE on the web page, you just wait a lot (10-15 minutes), then the correct data will come back to the web page, even if you do not reopen the spreadsheets.

Anyway, to avoid this problem, you can make a worksheet "publicSheet" within the master spreadhseet A, fill it with formulas that copy necessary things from the other worksheets, and publish this particular worksheet by File>Publish to the web>"publicSheet". If you do so, still nobody can access the other worksheets of the spreadsheet A, but the data will never disappear from the published worksheet.

查看更多
登录 后发表回答