1

I'm trying to create an lselect option by retrieving the data from my sheet but after many attempts I get nothing at all. My getPropertiesNamesList function retrieves the data but I can't display them in the select

code.gs

const getPropertiesNamesList = () => {
  try {
    const propertiesSheet = getSs(jamPropertyManagementSettingsSpreadsheetId).getSheetByName('Properties');
    const propertiesNamesList = getSheetHeaders(propertiesSheet);
    return propertiesNamesList;
  } catch (error) {
    Logger.log(`getPropertiesNamesListError: ${error.message}`);
    return `getPropertiesNamesListError: ${error.message}`;
  };
};

Script.html


$(function() {
  google.script.run.withSuccessHandler(showProperty)
      .getPropertiesNamesList();
});

function showProperty(property) {
  var list = $('#propertyNameList');
  list.empty();
  for (var i = 0; i < property.length; i++) {
    list.append('<option>' + property[i] + '</option>');
  }
}

index.html

 <label for="property" class="form-label">Property</label>
     <select class="selectpicker form-control"
       data-live-search="true" title="Choose a Property" name="propertyNameList"   id="propertyNameList" required>
                                                                    
  </select>
Rubén
  • 34,714
  • 9
  • 70
  • 166
Ulrich
  • 23
  • 4
  • About `My getPropertiesNamesList function retrieves the data`, can you provide the sample value and your script of `getSheetHeaders()`? – Tanaike Dec 08 '22 at 12:26
  • https://stackoverflow.com/a/49578427/7215091 – Cooper Dec 08 '22 at 21:43
  • const getSheetHeaders = (sheet) => { return sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]; }; – Ulrich Dec 08 '22 at 22:03
  • [property1, property2] the data format returned by the getPropertiesNamesList function – Ulrich Dec 08 '22 at 22:29

0 Answers0