function submitForm(e) {
  var res = e['formInput'];
  try {
    FIELDNAMES.forEach(function(fieldName) {
      if (! res[fieldName]) {
        throw 'incomplete form';
      }
    });
    var sheet = SpreadsheetApp
      .openByUrl((res['Spreadsheet URL']))
      .getActiveSheet();
    sheet.appendRow(objToArray(res, FIELDNAMES.slice(0, FIELDNAMES.length - 1)));
    PropertiesService.getUserProperties().setProperty('SPREADSHEET_URL', res['Spreadsheet URL']);
    return createExpensesCard(null, 'Logged expense successfully!').build();
  }
  catch (err) {
    if (err == 'Exception: Invalid argument: url') {
      err = 'Invalid URL';
      res['Spreadsheet URL'] = null;
    }
    return createExpensesCard(objToArray(res, FIELDNAMES), 'Error: ' + err).build();
  }
}
/**
 * Logs form inputs into a spreadsheet given by URL from form.
 * Then displays edit card.
 *
 * @param {Event} e An event object containing form inputs and parameters.
 * @returns {Card}
 */
Logs form inputs into a spreadsheet given by URL from form.
Then displays edit card.

@param {Event} e An event object containing form inputs and parameters.
@returns {Card}
Logs form inputs into a spreadsheet given by URL from form . Then displays edit card . @param { Event } e An event object containing form inputs and parameters . @returns { Card }
function submitForm(e) {
  var res = e['formInput'];
  try {
    FIELDNAMES.forEach(function(fieldName) {
      if (! res[fieldName]) {
        throw 'incomplete form';
      }
    });
    var sheet = SpreadsheetApp
      .openByUrl((res['Spreadsheet URL']))
      .getActiveSheet();
    sheet.appendRow(objToArray(res, FIELDNAMES.slice(0, FIELDNAMES.length - 1)));
    PropertiesService.getUserProperties().setProperty('SPREADSHEET_URL', res['Spreadsheet URL']);
    return createExpensesCard(null, 'Logged expense successfully!').build();
  }
  catch (err) {
    if (err == 'Exception: Invalid argument: url') {
      err = 'Invalid URL';
      res['Spreadsheet URL'] = null;
    }
    return createExpensesCard(objToArray(res, FIELDNAMES), 'Error: ' + err).build();
  }
}
function submitForm ( e ) { var res = e [ 'formInput' ] ; try { FIELDNAMES . forEach ( function ( fieldName ) { if ( ! res [ fieldName ] ) { throw 'incomplete form' ; } } ) ; var sheet = SpreadsheetApp . openByUrl ( ( res [ 'Spreadsheet URL' ] ) ) . getActiveSheet ( ) ; sheet . appendRow ( objToArray ( res , FIELDNAMES . slice ( 0 , FIELDNAMES . length - 1 ) ) ) ; PropertiesService . getUserProperties ( ) . setProperty ( 'SPREADSHEET_URL' , res [ 'Spreadsheet URL' ] ) ; return createExpensesCard ( null , 'Logged expense successfully!' ) . build ( ) ; } catch ( err ) { if ( err == 'Exception: Invalid argument: url' ) { err = 'Invalid URL' ; res [ 'Spreadsheet URL' ] = null ; } return createExpensesCard ( objToArray ( res , FIELDNAMES ) , 'Error: ' + err ) . build ( ) ; } }
Logs form inputs into a spreadsheet given by URL from form.
Logs form inputs into a spreadsheet given by URL from form .