Skip to content

Instantly share code, notes, and snippets.

@Jzarecta
Created November 23, 2018 08:54
Show Gist options
  • Save Jzarecta/b1884c108a0f782f94ca0d3d57bdbecc to your computer and use it in GitHub Desktop.
Save Jzarecta/b1884c108a0f782f94ca0d3d57bdbecc to your computer and use it in GitHub Desktop.
Filtrando la pregunta
/**
* Converts the given form URL into a JSON object.
*/
function onFormSubmit(e) {
var formResponses = FormApp.getActiveForm().getResponses();
var formResponse = formResponses[formResponses.length-1];
var itemResponses = formResponse.getItemResponses();
var result = getParamsForTrello( itemResponses );
Logger.log( result );
createTrelloCard(result);
}
function getParamsForTrello ( questions ) {
var result = {};
/*for(questions in form) {
if(questions[questions++]){
}
}*/
result.name = questions[1].getResponse();
result.description = questions[2].getResponse() + ": " + questions[4].getResponse();
return result;
}
function createTrelloCard( params ) {
//POST [/1/cards], Required permissions: write
var payload = {"name": params.name,
"desc": params.description,
"pos": "top",
"idList": ID_LIST
};
var url = URL_API_TRELLO + '/cards?key='+ TOKEN_API_KEY + '&token=' + TOKEN_TRELLO;
var options = {"method" : "post",
"payload" : payload};
Logger.log(UrlFetchApp.fetch(url, options));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment