Angularjs - get selected values by each function - angularjs

How can I implement the following function in Angularjs?
var TEST = [];
$('#div').find('select.test').each(function(){TEST.push($(this).val())});
And then with this values I would like update the ng-model value, like this:
$scope.formData.TEST = TEST.join(",");

This is my solution:
var TEST_ITEMS = [];
var testValues = document.getElementsByClassName('test');
for (var i = 0; i < testValues.length; ++i) {
var item = testValues[i];
var _testValues = item.options[item.selectedIndex].value;
console.log(_testValues);
TEST_ITEMS.push(_testValues);
}
$scope.formData.TEST = TEST_ITEMS.join(",");

Related

How do I get unique values after getRespondentEmail in google apps script?

I've been trying without success to get unique values from an array, after creating the array from getRespondentEmail in google apps script. I've tried to use the set method, the forEach etc for this and each time it returns an empty array or empty curly brackets. This is a sample of my code:
function test(){
var form = FormApp.openById('...');
form.setCollectEmail(true);
var formResponses = form.getResponses();
var getEmails = [];
var uniqueResponses = [...new Set(getEmails)];
for (var i = 0; i < formResponses.length; i++) {
var formResponse = formResponses[i];
var oneEmail = formResponse.getRespondentEmail();
getEmails.push(oneEmail);
}
Logger.log(uniqueResponses);
}
Does anyone know what the problem might be? I'm stuck. Thank you so much.
In your script, how about the following modification?
Modified script:
function test(){
var form = FormApp.openById('...');
form.setCollectEmail(true);
var formResponses = form.getResponses();
var getEmails = [];
for (var i = 0; i < formResponses.length; i++) {
var formResponse = formResponses[i];
var oneEmail = formResponse.getRespondentEmail();
getEmails.push(oneEmail);
}
var uniqueResponses = [...new Set(getEmails)];
Logger.log(uniqueResponses);
}
In your script, when var uniqueResponses = [...new Set(getEmails)] is run, getEmails has no value. By this, your issue occurs. In this modification, var uniqueResponses = [...new Set(getEmails)] is used after getEmails has the values. By this, the duplicated values are removed.
Reference:
Set

getRange of null error on code that previously worked

I searched the other instances of people reporting a "getRange" of null error, but none of them solved my issue. I had a form built in Google Sheets, and the code worked perfectly this morning until I made an inadvertent edit, tried to undo the change, but nonetheless I must have done something because the script stopped working.
The script is meant to:
Allow a user to create a record by inputing information using code 1000 on the Form sheet, and to save such information to the Data sheet
Display a record's information from the Data sheet on the Form sheet when the user enters a code greater than 1000 (a record locator ID)
Permit the user to update and save information for the record displayed
Reset the form to blank when either the new record is created, or the existing record has been updated.
It worked perfectly this morning, then kaput. I've been trying to debug unsuccessfully for hours, and here are error messages by function:
submitData
TypeError: Cannot read property 'getRange' of null (line 98, file
"Code")
getMember
Exception: Range not found (line 249, file "Code")
onEdit
TypeError: Cannot read property 'getActiveCell' of null (line 378,
file "Code")
I've been through every line of code, and I am stuck. I humbly request another pair of eyes to help me fix it. Below is the code, and here is a link to a copy of the form and data table I created with a sample row of data. Please ignore the data validation errors since I deleted proprietary information to create this copy, and please let me know if you have any questions. Thank you.
'''
//array for setValue on Data Centre and getValue by column from database
var cellId = ["J3","A"];
var cellPhoto = ["J32","B"];
//Location
var cellStreetAddress = ["D7","C"];
var cellCity = ["D8","D"];
var cellState = ["D9","E"];
var cellZip = ["D10","F"];
var cellCounty = ["D11","G"];
//Program data
var cellfiftyfive = ["H7","H"];
var cellIL = ["H8","I"];
var cellAL = ["H9","J"];
var cellMC = ["H10","K"];
var cellBeds = ["H12","L"];
//Property Summary
var cellPhase = ["K7","M"];
var cellLand = ["K8","N"];
var cellBuildable = ["K9","O"];
var cellPrice = ["K10","P"];
var cellGrade = ["K11","Q"];
var cellSource = ["K12","R"];
var cellClassification = ["K13","S"];
//Description
var cellSiteDescription = ["D16","T"];
var cellProjDescription = ["D21","U"];
//Site Information
var cellSiteVisit = ["L16","V"];
var cellTeamsLink = ["K17","W"];
var cellGoogleMap = ["K18","X"];
//Zoning
var cellZoningClass = ["K21","Y"];
var cellZoningDesc = ["K22","Z"];
var cellEntitlements = ["K23","AA"];
//Construction
var cellParkingType = ["K26","AB"];
var cellConstType = ["K27","AC"];
var cellUnitSizeRange = ["K28","AD"];
var cellTotalSqFt = ["K29","AE"];
//Financial
var cellTotalCost = ["D32","AF"];
var cellTotalCostDoor = ["D33","AG"];
var cellTotalCostSF = ["D34","AH"];
var cellTotalDebt = ["D35","AI"];
var cellTotalEquity = ["D36","AJ"];
var cellFDGEquity = ["D37","AK"];
var cellCapitalStructure = ["D38","AL"];
//EARLY
var cellDateProcessed = ["H42","AM"];
var cellMarketStudyLink = ["H43","AN"];
//Site Photo
var cellPhotoLibrary = ["K43","AO"];
//Stakeholders
var cellCoDev = ["D46","AP"];
var cellFeeDev = ["D47","AQ"];
var cellOperator = ["D48","AR"];
var cellPartner = ["D49","AS"];
var cellArchitect = ["D50","AT"];
var cellEngineer = ["D51","AU"];
var cellContractor = ["D52","AV"];
var cellBroker = ["D53","AW"];
//Schedule
var cellRezoning = ["H46","AX"];
var cellSitePlan = ["H48","AY"];
var cellPlanPermit = ["H49","AZ"];
var cellClosing = ["H50","BA"];
var cellExtensions = ["H51","BB"];
var cellTimeToClose = ["H52","BC"];
var cellEstConstStart = ["H54","BD"];
var cellEstConstLength = ["H55","BE"];
var cellEstConstFinish = ["H56","BF"];
//Additional Notes
var cellNotes = ["J46","BG"];
var cellDropped = ["J55","BH"];
//Date Stamps
var cellInputDate = ["L3","BI"];//var cellInputDate = ["D23","K"];
var cellUpdateDate = ["L4","BJ"];//var cellUpdateDate = ["H23","L"];
function submitData() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var formSS = ss.getSheetByName("Form");
var datasheet = ss.getSheetByName("Data");
var lastrow = datasheet.getLastRow();
var myId = formSS.getRange(cellId[0]).getValue();
var maxId = findMaxId(datasheet.getRange("A2:" + "A" + lastrow).getValues());
var nextId = increaseId(maxId);
var lastRowId = datasheet.getRange(lastrow,1,1,1).getValue();
var nextId = increaseId(lastRowId);
var myId = formSS.getRange(cellId[0]).getValue();
var now = new Date();
//Location
var my_StreetAddress = formSS.getRange(cellStreetAddress[0]).getValue();
var my_City = formSS.getRange(cellCity[0]).getValue();
var my_State = formSS.getRange(cellState[0]).getValue();
var my_Zip = formSS.getRange(cellZip[0]).getValue();
var my_County = formSS.getRange(cellCounty[0]).getValue();
//Program
var my_fiftyfive = formSS.getRange(cellfiftyfive[0]).getValue();
var my_IL = formSS.getRange(cellIL[0]).getValue();
var my_AL = formSS.getRange(cellAL[0]).getValue();
var my_MC = formSS.getRange(cellMC[0]).getValue();
var my_Beds = formSS.getRange(cellBeds[0]).getValue();
//Property Summary
var my_Phase = formSS.getRange(cellPhase[0]).getValue();
var my_Land = formSS.getRange(cellLand[0]).getValue();
var my_Buildable = formSS.getRange(cellBuildable[0]).getValue();
var my_Price = formSS.getRange(cellPrice[0]).getValue();
var my_Grade = formSS.getRange(cellGrade[0]).getValue();
var my_Source = formSS.getRange(cellSource[0]).getValue();
var my_Classification = formSS.getRange(cellClassification[0]).getValue();
//Description
var my_SiteDescription = formSS.getRange(cellSiteDescription[0]).getValue();
var my_ProjDescription = formSS.getRange(cellProjDescription[0]).getValue();
//Site Information
var my_SiteVisit = formSS.getRange(cellSiteVisit[0]).getValue();
var my_TeamsLink = formSS.getRange(cellTeamsLink[0]).getValue();
var my_GoogleMap = formSS.getRange(cellGoogleMap[0]).getValue();
//Zoning
var my_ZoningClass = formSS.getRange(cellZoningClass[0]).getValue();
var my_ZoningDesc = formSS.getRange(cellZoningDesc[0]).getValue();
var my_Entitlements = formSS.getRange(cellEntitlements[0]).getValue();
//Construction
var my_ParkingType = formSS.getRange(cellParkingType[0]).getValue();
var my_ConstType = formSS.getRange(cellConstType[0]).getValue();
var my_UnitSizeRange = formSS.getRange(cellUnitSizeRange[0]).getValue();
var my_TotalSqFt = formSS.getRange(cellTotalSqFt[0]).getValue();
//Financial
var my_TotalCost = formSS.getRange(cellTotalCost[0]).getValue();
var my_TotalCostDoor = formSS.getRange(cellTotalCostDoor[0]).getValue();
var my_TotalCostSF = formSS.getRange(cellTotalCostSF[0]).getValue();
var my_TotalDebt = formSS.getRange(cellTotalDebt[0]).getValue();
var my_TotalEquity = formSS.getRange(cellTotalEquity[0]).getValue();
var my_FDGEquity = formSS.getRange(cellTotalEquity[0]).getValue();
var my_CapitalStructure = formSS.getRange(cellCapitalStructure[0]).getValue();
//EARLY
var my_DateProcessed = formSS.getRange(cellDateProcessed[0]).getValue()
var my_MarketStudyLink = formSS.getRange(cellMarketStudyLink[0]).getValue()
//Site Photo
var my_Photo = formSS.getRange(cellPhoto[0]).getValue();
var my_PhotoLibrary = formSS.getRange(cellPhotoLibrary[0]).getValue();
//Stakeholders
var my_CoDev = formSS.getRange(cellCoDev[0]).getValue();
var my_FeeDev = formSS.getRange(cellFeeDev[0]).getValue();
var my_Operator = formSS.getRange(cellOperator[0]).getValue();
var my_Partner = formSS.getRange(cellPartner[0]).getValue();
var my_Architect = formSS.getRange(cellArchitect[0]).getValue();
var my_Engineer = formSS.getRange(cellEngineer[0]).getValue();
var my_Contractor = formSS.getRange(cellContractor[0]).getValue();
var my_Broker = formSS.getRange(cellBroker[0]).getValue();
//Schedule
var my_Rezoning = formSS.getRange(cellRezoning[0]).getValue();
var my_SitePlan = formSS.getRange(cellSitePlan[0]).getValue();
var my_PlanPermit = formSS.getRange(cellPlanPermit[0]).getValue();
var my_Closing = formSS.getRange(cellClosing[0]).getValue();
var my_Extensions = formSS.getRange(cellExtensions[0]).getValue();
var my_TimeToClose = formSS.getRange(cellTimeToClose[0]).getValue();
var my_EstConstStart = formSS.getRange(cellEstConstStart[0]).getValue();
var my_EstConstLength = formSS.getRange(cellEstConstLength[0]).getValue();
var my_EstConstFinish = formSS.getRange(cellEstConstFinish[0]).getValue();
//Additional Notes
var my_Notes = formSS.getRange(cellNotes[0]).getValue();
var my_Dropped = formSS.getRange(cellDropped[0]).getValue();
if (myId == 1000) { //input mode
var values = [
nextId,'',my_StreetAddress,my_City,my_State,my_Zip,my_County,my_fiftyfive,my_IL,my_AL,my_MC,my_Beds,my_Phase,my_Land,my_Buildable,my_Price,my_Grade,
my_Source,my_Classification,my_SiteDescription,my_ProjDescription,my_SiteVisit,my_TeamsLink,my_GoogleMap,my_ZoningClass,my_ZoningDesc,my_Entitlements,
my_ParkingType,my_ConstType,my_UnitSizeRange,my_TotalSqFt,my_TotalCost,my_TotalCostDoor,my_TotalCostSF,my_TotalDebt,my_TotalEquity,my_FDGEquity,my_CapitalStructure,
my_DateProcessed,my_MarketStudyLink,my_PhotoLibrary,my_CoDev,my_FeeDev,my_Operator,my_Partner,my_Architect,my_Engineer,
my_Contractor,my_Broker,my_Rezoning,my_SitePlan,my_PlanPermit,my_Closing,my_Extensions,my_TimeToClose,
my_EstConstStart,my_EstConstLength,my_EstConstFinish,my_Notes,my_Dropped,now
];
datasheet.getRange(datasheet.getLastRow()+1, 1, 1, 61).setValues(values);
clear_screen();
} else { //update mode
var rowIndex = findInRow(myId);
var rangesToSetValues = [cellStreetAddress[1], cellCity[1], cellState[1], cellZip[1], cellCounty[1], cellfiftyfive[1], cellIL[1],
cellAL[1], cellMC[1], cellBeds[1], cellPhase[1], cellLand[1], cellBuildable[1],
cellPrice[1], cellGrade[1], cellSource[1], cellClassification[1], cellSiteDescription[1], cellProjDescription[1],
cellSiteVisit[1], cellTeamsLink[1], cellGoogleMap[1], cellZoningClass[1], cellZoningDesc[1], cellEntitlements[1],
cellParkingType[1], cellConstType[1], cellUnitSizeRange[1], cellTotalSqFt[1],cellTotalCost[1], cellTotalCostDoor[1], cellTotalCostSF[1],
cellTotalDebt[1], cellTotalEquity[1], cellFDGEquity[1], cellCapitalStructure[1], cellDateProcessed[1], cellMarketStudyLink[1], cellPhotoLibrary[1],
cellCoDev[1], cellFeeDev[1], cellOperator[1], cellPartner[1], cellArchitect[1], cellEngineer[1],
cellContractor[1], cellBroker[1], cellRezoning[1], cellSitePlan[1], cellPlanPermit[1], cellClosing[1],
cellExtensions[1], cellTimeToClose[1], cellEstConstStart[1], cellEstConstLength[1], cellEstConstFinish[1], cellNotes[1],cellDropped[1]];
var values = [
my_StreetAddress,my_City,my_State,my_Zip,my_County,my_fiftyfive,my_IL,my_AL,my_MC,my_Beds,my_Phase,my_Land,my_Buildable,my_Price,my_Grade,
my_Source,my_Classification,my_SiteDescription,my_ProjDescription,my_SiteVisit,my_TeamsLink,my_GoogleMap,my_ZoningClass,my_ZoningDesc,my_Entitlements,
my_ParkingType,my_ConstType,my_UnitSizeRange,my_TotalSqFt,my_TotalCost,my_TotalCostDoor,my_TotalCostSF,my_TotalDebt,my_TotalEquity,my_FDGEquity,my_CapitalStructure,
my_DateProcessed,my_MarketStudyLink,my_PhotoLibrary,my_CoDev,my_FeeDev,my_Operator,my_Partner,my_Architect,my_Engineer,
my_Contractor,my_Broker,my_Rezoning,my_SitePlan,my_PlanPermit,my_Closing,my_Extensions,my_TimeToClose,my_EstConstStart,my_EstConstLength,
my_EstConstFinish,my_Notes,my_Dropped
];
for (var i=0; i<rangesToSetValues.length; i++) {
datasheet.getRange(rangesToSetValues[i]+rowIndex).setValue(values[i]);
}
//set lastupdateDate value
datasheet.getRange(cellUpdateDate[1]+rowIndex).setValue(now);
getMember(myId);
}
}
function getMember(id) {
var sheetData = SpreadsheetApp.getActive().getSheetByName('Form');
var rangesToSetValues = [cellStreetAddress[0], cellCity[0], cellState[0], cellZip[0], cellCounty[0], cellfiftyfive[0], cellIL[0],
cellAL[0], cellMC[0], cellBeds[0], cellPhase[0], cellLand[0], cellBuildable[0],
cellPrice[0], cellGrade[0], cellSource[0], cellClassification[0], cellSiteDescription[0], cellProjDescription[0],
cellSiteVisit[0], cellTeamsLink[0], cellGoogleMap[0], cellZoningClass[0], cellZoningDesc[0], cellEntitlements[0],
cellParkingType[0], cellConstType[0], cellUnitSizeRange[0], cellTotalSqFt[0], cellTotalCost[0], cellTotalCostDoor[0], cellTotalCostSF[0],
cellTotalDebt[0], cellTotalEquity[0], cellFDGEquity[0], cellCapitalStructure[0], cellDateProcessed[0], cellMarketStudyLink[0], cellPhotoLibrary[0],
cellCoDev[0], cellFeeDev[0], cellOperator[0], cellPartner[0], cellArchitect[0], cellEngineer[0],
cellContractor[0], cellBroker[0], cellRezoning[0], cellSitePlan[0], cellPlanPermit[0], cellClosing[0],
cellExtensions[0], cellTimeToClose[0], cellEstConstStart[0], cellEstConstLength[0], cellEstConstFinish[0], cellNotes[0], cellDropped[0],
cellInputDate[0], cellUpdateDate[0]];
var rowIndex = findInRow(id);
var sheetDatabase = SpreadsheetApp.getActive().getSheetByName('Data');
var values = [
//Location
sheetDatabase.getRange(cellStreetAddress[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellCity[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellState[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellZip[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellCounty[1]+rowIndex).getValue(),
//Program data
sheetDatabase.getRange(cellfiftyfive[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellIL[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellAL[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellMC[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellBeds[1]+rowIndex).getValue(),
//Property Summary
sheetDatabase.getRange(cellPhase[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellLand[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellBuildable[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellPrice[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellGrade[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellSource[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellClassification[1]+rowIndex).getValue(),
//Description
sheetDatabase.getRange(cellSiteDescription[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellProjDescription[1]+rowIndex).getValue(),
//Site Information
sheetDatabase.getRange(cellSiteVisit[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellTeamsLink[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellGoogleMap[1]+rowIndex).getValue(),
//Zoning
sheetDatabase.getRange(cellZoningClass[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellZoningDesc[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellEntitlements[1]+rowIndex).getValue(),
//Construction
sheetDatabase.getRange(cellParkingType[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellConstType[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellUnitSizeRange[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellTotalSqFt[1]+rowIndex).getValue(),
//Financial
sheetDatabase.getRange(cellTotalCost[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellTotalCostDoor[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellTotalCostSF[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellTotalDebt[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellTotalEquity[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellFDGEquity[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellCapitalStructure[1]+rowIndex).getValue(),
//EARLY
sheetDatabase.getRange(cellDateProcessed[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellMarketStudyLink[1]+rowIndex).getValue(),
//Site Photo
//sheetDatabase.getRange(cellPhoto[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellPhotoLibrary[1]+rowIndex).getValue(),
//Stakeholders
sheetDatabase.getRange(cellCoDev[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellFeeDev[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellOperator[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellPartner[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellArchitect[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellEngineer[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellContractor[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellBroker[1]+rowIndex).getValue(),
//Schedule
sheetDatabase.getRange(cellRezoning[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellSitePlan[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellPlanPermit[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellClosing[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellExtensions[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellTimeToClose[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellEstConstStart[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellEstConstLength[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellEstConstFinish[1]+rowIndex).getValue(),
//Additional Notes
sheetDatabase.getRange(cellNotes[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellDropped[1]+rowIndex).getValue(),
//Data Stamps
sheetDatabase.getRange(cellInputDate[1]+rowIndex).getValue(),
sheetDatabase.getRange(cellUpdateDate[1]+rowIndex).getValue()
];
for (var i=0; i<rangesToSetValues.length; i++) {
sheetData.getRange(rangesToSetValues[i]).setValue(values[i]);
}
}
function findInRow(id) {
var sheetDatabase = SpreadsheetApp.getActive().getSheetByName('Data');
var rows = sheetDatabase.getRange("A2:A").getValues();
for (var r=0; r<rows.length; r++) {
if ( rows[r][0] === id ) {
return r+2;
}
}
return -1;
}
function increaseId(id) {
if(id>0) {
var returnId;
returnId = id + 1;
return returnId;
}
}
function findMaxId(myvalues){
return Math.max.apply(null, myvalues);
}
function onOpen(e) {
//initialization
/*var sheet = SpreadsheetApp.getActive().getSheetByName('Form'); //var sheet = SpreadsheetApp.getActive().getSheetByName('Reception');
sheet.getRange(cellId[0]).setValue(1000);
clear_screen();*/
}
function onEdit(e) {
//e.source.setActiveSelection(e.range.offset(2, 0));
var sheet = SpreadsheetApp.getActive().getSheetByName('Form');
var rangeRowId = sheet.getActiveCell().getRow();
var rangeColId = sheet.getActiveCell().getColumn();
//Browser.msgBox("Row Id: " + rangeRowId + " Column Id: " + rangeColId );
if(rangeRowId == 3 && rangeColId == 10) {
var myId = sheet.getRange(cellId[0]).getValue();
lookUpId(myId);
}
}
function clear_screen() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Form');
var rangesToClear = [cellStreetAddress[0], cellCity[0], cellState[0], cellZip[0], cellCounty[0], cellfiftyfive[0], cellIL[0],
cellAL[0], cellMC[0], cellBeds[0], cellPhase[0], cellLand[0], cellBuildable[0],
cellPrice[0], cellGrade[0], cellSource[0], cellClassification[0], cellSiteDescription[0], cellProjDescription[0],
cellSiteVisit[0], cellTeamsLink[0], cellGoogleMap[0], cellZoningClass[0], cellZoningDesc[0], cellEntitlements[0],
cellParkingType[0], cellConstType[0], cellUnitSizeRange[0], cellTotalSqFt[0], cellTotalCost[0], cellTotalCostDoor[0], cellTotalCostSF[0],
cellTotalDebt[0], cellTotalEquity[0], cellFDGEquity[0], cellCapitalStructure[0], cellDateProcessed[0], cellMarketStudyLink[0], cellPhotoLibrary[0], cellCoDev[0],
cellFeeDev[0], cellOperator[0], cellPartner[0], cellArchitect[0], cellEngineer[0], cellContractor[0], cellBroker[0], cellRezoning[0],
cellSitePlan[0], cellPlanPermit[0], cellClosing[0], cellExtensions[0], cellTimeToClose[0], cellEstConstStart[0], cellEstConstLength[0],
cellEstConstFinish[0], cellNotes[0], cellDropped[0], cellInputDate[0], cellUpdateDate[0]];
for (var i=0; i<rangesToClear.length; i++) {
sheet.getRange(rangesToClear[i]).clearContent();
}
var myCellStreetAddress = sheet.getRange(cellStreetAddress[0]);
myCellStreetAddress.activateAsCurrentCell();
}
function lookUpId(id) {
if (id==1000) { //Data Centre mode
clear_screen();
}
if (id>1000) { //lookup mode
getMember(id);
}
}
'''

Loop and export only one tab

I have a script that's working well - it takes a value from a list (employee ID) and inserts it into the 'Scorecard' tab - the script then outputs all employee scorecards as .pdfs. Only problem I'm running into is the script is exporting both tabs to the .pdf as opposed to only the scorecard... any thoughts?
function loop() {
var targetFolderId = "11rc9rFM25lnLArxm0yk588UEH5MD-NpR";
var targetFolder = DriveApp.getFolderById(targetFolderId);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var validation_sheet = ss.getSheetByName('Performance_Scores');
var lastRow = validation_sheet.getLastRow();
var inputs = ss.getSheetByName('Performance_Scores').getRange('A2:A'+lastRow).getValues();
var tab = ss.getSheetByName('Scorecard');
//Loop
for (var i = 0; i < inputs.length; i++) {
tab.getRange('B2').setValue(inputs[i][0]);
SpreadsheetApp.flush();
Utilities.sleep(5000);
//Print PDFs
var name = tab.getRange(2, 2).getValue();
targetFolder.createFile(ss.getAs('application/pdf')).setName(name);
}
}
Try this:
function loop() {
var targetFolder=DriveApp.getFolderById("11rc9rFM25lnLArxm0yk588UEH5MD-NpR");
var ss=SpreadsheetApp.getActive();
var validation_sheet=ss.getSheetByName('Performance_Scores').hideSheet();
var inputs=validation_sheet.getRange(2,1,validation_sheet.getLastRow(),1).getValues();
var tab=ss.getSheetByName('Scorecard').showSheet();
for (var i=0; i < inputs.length; i++) {
tab.getRange('B2').setValue(inputs[i][0]);
SpreadsheetApp.flush();
Utilities.sleep(5000);
var name=tab.getRange(2, 2).getValue();
targetFolder.createFile(ss.getAs('application/pdf')).setName(name);
}
}

TyperError: Cannot read property "length" of undefined --- but it is defined?

Uncaught TypeError: Cannot read property 'length' of undefined
at buildTable (test.js:14)
at test.js:2
I'm not entirely sure what is happening here. I am getting this error, it seems like its saying my array is undefined, but it is defined?
edit: its referring to the code in the loop.
var table = document.getElementById("tableBody");
buildTable();
var toDoArray = [];
function buildTable(){
var retrievedTaskObject = localStorage.getItem("task");
var parsedObject = JSON.parse(retrievedTaskObject);
var addTheTaskName = parsedObject.taskName;
var addTheTaskDate = parsedObject.taskDate;
for(i=0; i < toDoArray.length; i++){
addTaskToTable(parsedObject[i]);
}
}
function addTaskToTable(obj){
var row = table.insertRow(0);
var cellName = row.insertCell(0);
var cellDate = row.insertCell(1);
var cellId = row.insertCell(2);
var cellCheck = row.insertCell(3);
cellName.innerHTML= obj.name;
cellDate.innerHTML= obj.date;
var checkStuff = "<input type='checkbox'>";
cellCheck.innerHTML = checkStuff;
}
function submitForm(name,date) {
var addTaskName = document.getElementById("taskName").value;
var addTaskDate = document.getElementById("dateTask").value;
var taskSomething = getTaskObj(addTaskName,addTaskDate);
toDoArray.push(taskSomething);
addTaskToTable(taskSomething);
var storedArray = JSON.stringify(toDoArray);
localStorage.setItem("task",storedArray);
};
function getTaskObj(taskName,taskData){
var taskObject = {
name: taskName,
date: taskData,
};
return taskObject;
}
keep this before you call builtTable function
var toDoArray = [];
like
var toDoArray = [];
buildTable();
you are calling funtion and using array before defining..

Why $http response data are not shown in angular js?

I make a example of directive in angular js .I am using this directive
https://github.com/ONE-LOGIC/ngFlowchart
when I take static data ..it show the output please check my plunker
http://plnkr.co/edit/d2hAhkFG0oN3HPBRS9UU?p=preview
but when I use $http request and make same json object .it not display the chart see my plunker using $http request .I have same data object as in static
http://plnkr.co/edit/Vts6GdT0NNudZr2SJgVY?p=preview
$http.get('data.json').success(function(data) {
console.log(data)
var arr = data
var model={};
var new_array = []
for (var i = 0; i < arr.length; i++) {
var obj = {};
obj.name = arr[i].name;
obj.id = arr[i].id;
obj.x = arr[i].x;
obj.y = arr[i].y;
obj.color = '#000';
obj.borderColor = '#000';
var p = {};
p.type = 'flowchartConstants.bottomConnectorType';
p.id = arr[i].con_id
obj.connectors = [];
obj.connectors.push(p);
new_array.push(obj);
}
console.log('new array')
console.log(new_array)
model.nodes=new_array;
var edge = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i].children.length > 0) {
for (var j = 0; j < arr[i].children.length; j++) {
var obj = {};
obj.source = arr[i].con_id;
obj.destination = arr[i].children[j].con_id;
edge.push(obj);
}
}
}
model.edges=edge;
console.log(edge)
console.log("model")
console.log(JSON.stringify(model))
$scope.flowchartselected = [];
var modelservice = Modelfactory(model, $scope.flowchartselected);
$scope.model = model;
$scope.modelservice = modelservice;
})
any update ?
Working Example
It is now working.
The issue was when we load the directive first time it has no parameter value to it. So, when the chart directive try to initialize your chart with no parameter it gets an error. So, it will not work anymore.
How solve the issue?
Just give a dummy parameter upon the page load. I have given the dummy model as,
$scope.model = model;
$scope.modelservice = modelservice;
So, first your chart will display a chart based on the dummy values. After that it populates chart with the data from the server ($http.get())

Resources