2014-02-21 5 views
1

스프레드 시트 열 머리글을 양식의 질문으로 변환하는 스크립트를 작성하려고합니다. 스프레드 시트가있는 폴더에서이 스크립트를 실행하고 같은 폴더에 양식을 만들 수있게하고 싶습니다. 문제는, 내가 어디에 스크립트를 배치하든, 폼은 루트 폴더에 만들어집니다. Form 및 FormApp 설명서에 도움이되지 않았습니다. 나는스크립트를 사용하여 루트가 아닌 폴더에 양식 만들기

function createForm() 
{ 
    // Create a new form, then add a checkbox question, a multiple choice question, 
// a page break, then a date question and a grid of questions. 
var form = FormApp.create('New Form'); 
var form = FormApp.create('Form Name'); 
var item = form.addCheckboxItem(); 
item.setTitle('This is a bunch of gibberish!!!!!!!!!!!!'); 
item.setChoices([ 
     item.createChoice('Relish') 
    ]); 
Logger.log('Published URL: ' + form.getPublishedUrl()); 
Logger.log('Editor URL: ' + form.getEditUrl()); 
} 

답변

2

신속하고 더러운 솔루션은 다음과 같은 것 ... 그것은 함수 호출에 단순한 모드의 특정 해요,하지만 :

function createForm(){ 
//get the form file through id of the form you just made 
var form  = FormApp.create('tempForm'), 
    id  = form.getId(), 
    formFile = DriveApp.getFileById(id); 
//get the id of the folder you want to move the form to 
var folderId = DriveApp.getFolderById('folderID'); 
//delete the temporary form 
formFile.setTrashed(true); 
//copy the temp form (still active) to the destination folder, open it. 
var newId = formFile.makeCopy(folder).setName('myCopiedForm').getId(), 
    form  = FormApp.openById(newId); 
} 

그것은 더러운 만 작동합니다. 더 나은 해결책이 있다면 알려주십시오.

관련 문제