Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8829449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:50:09+00:00 2026-06-14T07:50:09+00:00

I am trying to save some user input from a Google App Script form

  • 0

I am trying to save some user input from a Google App Script form on a spreadsheet to the private cache.

Here is a test script:

var cache = CacheService.getPrivateCache();

function onLoad() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet(),
      entries = [{
        name : "Show form",
        functionName : "showForm"
      }];
  sheet.addMenu("Test Menu", entries);
}

function showForm() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(),
      app = UiApp.createApplication(),
      setButton = app.createButton("Set"),
      setHandler = app.createServerClickHandler('setTest');

  setButton.addClickHandler(setHandler);
  app.add(setButton);
  spreadsheet.show(app);
}

function setTest(event) {
  cache.put("test", "test", 7200);

  Browser.msgBox("Test was set: " + cache.get("test") + ". Use the getTest cell formula to test the cache.");
}

function getTest() {
  var result = cache.get("test");

  return result;
}

Once I click the menu button, a form appears and sets a cache value in a server handler. Then I try to get the value from the cache using =getTest() in a cell. I would expect the cache to return the value “test” but it seems to return null.

I started this issue here:
http://code.google.com/p/google-apps-script-issues/issues/detail?id=2039

And I also found another similar one:
http://code.google.com/p/google-apps-script-issues/issues/detail?id=1804

Trying to save some user input on a form into the cache and be able to access it from another function at a later time.

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:50:10+00:00Added an answer on June 14, 2026 at 7:50 am

    Custom functions have limited scope and then can only access a few select services. You read more about their limitations here.

    With Cache its a bit tricky – caching is per “script scope”. So when a Cache is accessed first from the Server handler script scope its running as a UiApp which has more privileges and that is different from the script scope that a custom function runs as. Therefore, the cache is not shared between those two scopes.

    You can access cached items that you set in custom functions from other custom functions, but this cache can’t cross these boundaries.

    You could theoretically store this in ScripProperties but that can very clumsy and it would be misusing those capabilities and this is shared amongst all users.

    ScriptProperties.setProperty("test", "test")
    

    and

    var result = ScriptProperties.getProperty("test");
    

    If you can explain your usecase a bit more in depth, perhaps we can provide some alternative solutions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to take a single input from the user and delete some
I have a WPF form that has some buttons to save user input, delete,
I'm trying to save some layouts from DevExpress Grid Controls so that users can
while trying to process some user input which contains characters such as <. I
I'm trying to catch WM_QUERYENDSESSION to save some data in the app, but it
I am currently trying to get my program to input data from a user-defined
I have a form that I'm trying to get information from the user when
I'm trying to save some data into an array but unfortunately all the data
I'm trying to save some UserControl-Infos into a List like this: List<UserControlDetails> myList; public
I'm trying to save some lookup table data out to a YAML file so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.