function editForm(e) {
  var res = e['formInput'];
  try {
    FIELDNAMES.slice(0, FIELDNAMES.length - 1).forEach(function(fieldName) {
      if (! res[fieldName]) {
        throw 'incomplete form';
      }
    });
    var props = PropertiesService.getUserProperties();
    var url = props.getProperty('SPREADSHEET_URL');
    var sheet = SpreadsheetApp.openByUrl(url).getActiveSheet();
    var id = parseInt(props.getProperty('EXPENSE_ID')) - 1;
    for (var i = sheet.getLastRow(); i > 0; i--) {
      if (sheet.getRange(i, 1).getValue() == id) {
        var newValues = objToArray(res, FIELDNAMES.slice(0, FIELDNAMES.length - 1));
        sheet.getRange(i, 2, 1, FIELDNAMES.length - 1).setValues([newValues]);
        return createEditCard(res, 'Edited expense successfully!').build();
      }
    }
    throw 'expense ID not found in sheet';
  }
  catch (err) {
    return createEditCard(res, 'Error: ' + err).build();
  }
}
/**
 * Edits most recent spreadsheet by removing bottom row and appending new information to sheet.
 * Then displays a edit card again.
 *
 * @param {Event} e An event object containing form inputs and parameters.
 * @returns {Card}
 */
Edits most recent spreadsheet by removing bottom row and appending new information to sheet.
Then displays a edit card again.

@param {Event} e An event object containing form inputs and parameters.
@returns {Card}
Edits most recent spreadsheet by removing bottom row and appending new information to sheet . Then displays a edit card again . @param { Event } e An event object containing form inputs and parameters . @returns { Card }
function editForm(e) {
  var res = e['formInput'];
  try {
    FIELDNAMES.slice(0, FIELDNAMES.length - 1).forEach(function(fieldName) {
      if (! res[fieldName]) {
        throw 'incomplete form';
      }
    });
    var props = PropertiesService.getUserProperties();
    var url = props.getProperty('SPREADSHEET_URL');
    var sheet = SpreadsheetApp.openByUrl(url).getActiveSheet();
    var id = parseInt(props.getProperty('EXPENSE_ID')) - 1;
    for (var i = sheet.getLastRow(); i > 0; i--) {
      if (sheet.getRange(i, 1).getValue() == id) {
        var newValues = objToArray(res, FIELDNAMES.slice(0, FIELDNAMES.length - 1));
        sheet.getRange(i, 2, 1, FIELDNAMES.length - 1).setValues([newValues]);
        return createEditCard(res, 'Edited expense successfully!').build();
      }
    }
    throw 'expense ID not found in sheet';
  }
  catch (err) {
    return createEditCard(res, 'Error: ' + err).build();
  }
}
function editForm ( e ) { var res = e [ 'formInput' ] ; try { FIELDNAMES . slice ( 0 , FIELDNAMES . length - 1 ) . forEach ( function ( fieldName ) { if ( ! res [ fieldName ] ) { throw 'incomplete form' ; } } ) ; var props = PropertiesService . getUserProperties ( ) ; var url = props . getProperty ( 'SPREADSHEET_URL' ) ; var sheet = SpreadsheetApp . openByUrl ( url ) . getActiveSheet ( ) ; var id = parseInt ( props . getProperty ( 'EXPENSE_ID' ) ) - 1 ; for ( var i = sheet . getLastRow ( ) ; i > 0 ; i -- ) { if ( sheet . getRange ( i , 1 ) . getValue ( ) == id ) { var newValues = objToArray ( res , FIELDNAMES . slice ( 0 , FIELDNAMES . length - 1 ) ) ; sheet . getRange ( i , 2 , 1 , FIELDNAMES . length - 1 ) . setValues ( [ newValues ] ) ; return createEditCard ( res , 'Edited expense successfully!' ) . build ( ) ; } } throw 'expense ID not found in sheet' ; } catch ( err ) { return createEditCard ( res , 'Error: ' + err ) . build ( ) ; } }
Edits most recent spreadsheet by removing bottom row and appending new information to sheet.
Edits most recent spreadsheet by removing bottom row and appending new information to sheet .