그래서 나는 방금 Javascript를 배우기 시작했다고 말하기 시작합니다. 4 일 전. 이제는이 스크립트로 내 의도입니다.주간 신문에 새 양식의 양식 응답을 복사하여 보관하는 Google 스크립트
스프레드 시트로 수집 된 Google 양식 응답을 보관 파일과 동일한 통합 문서 내에서 새 시트로 이동하는 과정을 자동화하고 싶습니다.
주간 단위로, 그리고 1 주일 만 응답하도록 작성된 각 보관 용 시트에 대해이 작업을 수행하고 싶습니다. 일요일 오전 12:01 ~ 1:00AM 사이에 있어야합니다. 실제로 발생하는 시간에는 문제가되지 않습니다.
또한 기본 응답 시트 (Current_Responses)에서 해당 응답을 모두 삭제하고 싶습니다. 그러나 나중에 수동으로 삭제해야하는 경우 스크립트가 올바르게 작동했는지 검토 할 수 있기 때문에 괜찮습니다.).
내가이 모든 것을 처음 접했을 때부터 경험이 많은 스크립터가 내 코드를 살펴보고 이것이 어떻게 작동하는지 알려주면 정말 고맙겠습니다. 그것을 의도하고, 그렇지 않다면 실수가있는 곳과 그것을 고치는 방법. 나는 실수를하게되어 기쁘다. 그리고 그들로부터 배울 것이므로 어떤 충고라도 깊게 존중할 것이다.
3 가지 웹 사이트에서 여러 주제와 스크립트를 조사하여이를 종합했습니다. 도움과 조언을 미리 보내 주셔서 감사합니다!
// function to copy from Current_Responses to new sheet 'Archived_Responses
//(UTC Date)' placed after Current_Responses
function CreateCopySheetWeekly() {
//source info
var ss = SpreadsheetApp.getActiveSpreadsheet();
var templateSheet = ss.getSheetByName('Current_Responses');
var range = ss.getRange ('A:I'); //replace column length as needed
var data = range.getValues();
//creates target sheet to copy responses to
var ts = 'Archived_Responses '+formatDate();
ss.insertSheet(sheetName, ss.getSheets().length, {template: templateSheet});
ts.getRange(ts.getLastRow()+1, 1, data.length, data[0].length).setValues(data);
}
//end of primary function
//function to determine and format UTC Date for CreateCopySheetWeekly function
function formatDate() {
var month, day, d = new Date();
month = ('0'+(d.getUTCMonth()+1)).slice(-2);
day = ('0'+(d.getUTCDate()).slice(-2);
return d.getUTCFullYear()+'-'+month+'-'+day;
}
//end of date function
//check every hour to determine when to perform newSheetLast function. Intended for Sunday
//between 0001-0100
window.setInterval (onSunday(){
var today = new Date();
if (today.getDay() == 0 && today.getHours() === 12) {
CreateCopySheetWeekly();
}, 600000);
저는이 부분에 익숙하지 않아 쉽게 움직이지 만 건설적인 비판은 결코 사람을 해치지 않습니다.