스프레드 시트의 Google App 스크립트 양식에서 일부 사용자 입력을 개인 캐시에 저장하려고합니다. 여기 서버 처리기에서 캐시 사용
는 테스트 스크립트입니다 : 나는 메뉴 버튼을 클릭하면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;
}
는, 형태가 나타나고 서버 핸들러에서 캐시 값을 설정합니다. 그런 다음 셀에서 = getTest()를 사용하여 캐시에서 값을 가져 오려고합니다. 캐시가 값 "test"를 리턴 할 것으로 기대하지만 null을 리턴하는 것으로 보입니다.
내가 여기에이 문제를 시작: http://code.google.com/p/google-apps-script-issues/issues/detail?id=2039
그리고 나는 또한 다른 유사한 하나 발견 : 캐시에 폼에 약간의 사용자 입력을 저장하고 서로에 액세스 할 수 있도록 노력 http://code.google.com/p/google-apps-script-issues/issues/detail?id=1804
을 나중에 작동합니다.
제안 사항?
메시지 상자에 올바른 값이 표시되어 있습니까? – Srik
캐시 값을 확인하는 팝업창이 실제로 setTest 함수에서 설정되었다는 메시지 상자 (msgBox)에 대해 말하면 yes입니다. – adrianb