2016-02-06 19 views
0

我已经编写了不到一周的代码,但我想我不会有这么多麻烦试图解决这个错误。通过其他例子来看,但我不太可能知道他们是如何应用于我的,因为他们都没有解决我的问题。下面是代码:无效的左侧分配。 (第1行,“代码”文件) - Google Apps脚本

function clearButtonClick() { 
 
    var ss = SpreadsheetApp.getActive(); 
 
    var sheet = ss.getActiveSheet(); 
 
    
 
    Logger.log('sheet.getName(): ' + sheet.getName()); 
 
    
 
    if (sheet.getName() !== "TimeCardEntry") {return;}; 
 
    
 
    sheet.getRange(8,2,12,12).clearContent(); 
 
    sheet.getRange(4,4).clearContent(); 
 
    sheet.getRange(4,11).clearContent(); 
 
} 
 

 

 
function submitButtonClick(){ 
 
    //Begining of entry8 transfer 
 
    
 
    var ss=SpreadsheetApp.getActive(); //Makes the active spreadsheet available for the program to act on 
 
    var sheet = ss.getActiveSheet(); //Makes the active sheet available 
 
    Logger.log('The active sheet is: ' + sheet.getName()); //Writes the sheet name to the log so it can be checked 
 
    
 
    while(sheet.getName() =="TimeCardEntry"){ //If you are on the correct sheet when you try to run... 
 
//change 8 
 
    var cellB8 = sheet.getRange(8,2).getValue(); //Pulls in the value of "B8" 
 
//change 8  
 
    if(cellB8 === "") {return}; //If B8 is not blank, or in other words, B8 has something in it, then... 
 
     var targetSheet = ss.getSheetByName("TimesheetRecord"); //Pulls in the target sheet name 
 
     var arrayOfData = []; //Creates the array to temporarily hold the data until it writes to target sheet 
 
    
 
     
 
     var weekBegining = sheet.getRange(4,11).getValue(); //Stores the value of the "Sunday at the Begining of the Week Date" 
 
     var employName = sheet.getRange(4,4).getValue(); //Stores the name of the employee from D4 
 
//change 8  
 
     var entry8 = sheet.getRange(8,2,1,9); //pulls in row 8 data to be worked on 
 
//change 8  
 
     var entry8Data = entry8.getValues()[0]; //pulls row 8 into an inner array 
 
//change 8  
 
     Logger.log('Line 8 data is:' = entry8Data); //logs what the data is so you can make sure it got the right stuff  
 
     entry*Data.splice (0,0,weekBegining,employName); //Add weekBegining and employName values to the entry data array 
 
//change 8 
 
     arrayOfData.push(entry8Data); //Push row data for entry 8 into an outer array because setValues() can't use nested arrays 
 
     Logger.log('Array of data is: ' + arrayOfData); //writes the combined data array to the log 
 
     
 
     var lastRow = targetSheet.getLastRow(); //stores the number of the last row with entries in the target sheet 
 
     Logger.log('Last Row is: ' + lastRow); //logs what the last row is for reference 
 
//change 8  
 
     targetSheet.getRange(lastRow+1,1,1,entry8Data.length).seValues(arrayOfData); //Adds 1 row to the lastfilled row then selects that row (1st empty one) and 1 row deep by the number of columns in the arrayOfData then copies the arrayOfData values to it. 
 
//change 8  
 
     sheet.getRange(8,2,1,9).clearContent(); //goes back to the original sheet and deletes the row 8 data. 
 
     
 
    } 
 
    } 
 

 

 
function emailLog(){ 
 
//Send an email to yourself with the log from running this script so you can see if any values were wrong 
 
//Comment all this out once the script work right 
 
    var emailRecipient = Session.getActiveUser().getEmail(); 
 
    var emailSubject = 'Log of the last run of Paradigm Weekly Time Card' ; 
 
    var emailBody = Logger.getLog(); 
 
    MailApp.sendEmail(emailRecipient, emailSubject, emailBody); 
 
} 
 
    

Google App Script Error Invalid assignment left-hand side. (line 1, file "Code")

温柔,这是我的第一次。 ;)

+0

其中一个答案能解决您的问题吗?如果是这样,请接受该答案。 –

+0

对不起,这个还是新的。忘记了你需要。 – JLBJones

回答

1

你就行了错字:

Logger.log('Line 8 data is:' = entry8Data); 

我想你的意思:

Logger.log('Line 8 data is:' + entry8Data); 

而且,最好的做法是始终使用===比较的东西,从来没有== :)