Can anyone help me. I have a moderate amount of experience in javascript but for the life of my I can not figure this out. This code is transferring data from one sheet to another in a series of other functions being run. I have limited it to just this function to troubleshoot the problem, so I know its not any other code I have written.
Here is my code:
if (school == 'PE') {
var admin_sheet = ss.getSheets()[3];}
else if (school == 'Archive') {
var admin_sheet = ss.getSheets()[2];}
else if (school =='Notify') {
var admin_sheet = ss.getSheets()[1];}
var lastRow = admin_sheet.getLastRow()+1;
var lCol = admin_sheet.getLastColumn();
It works the best if it is written to not compare both sides:
if (school = 'PE') {
var admin_sheet = ss.getSheets()[3];}
else if (school = 'Archive') {
var admin_sheet = ss.getSheets()[2];}
else if (school ='Notify') {
var admin_sheet = ss.getSheets()[1];}
var lastRow = admin_sheet.getLastRow()+1;
var lCol = admin_sheet.getLastColumn();
The problem is it is not reliable. Here is the log
[20-06-08 09:09:15:563 PDT] Jonathan Smith
[20-06-08 09:09:15:564 PDT] Grade 11
[20-06-08 09:09:15:566 PDT] 253426
[20-06-08 09:09:15:568 PDT] Archive
When it transfers it to the new sheet it is not on the Archive Sheet but the Pre-Enrolled sheet and it lists the school as PE (Pre-Enrolled). It is obviously pulling the data correctly as the correct school is listed as Archive, and I can't understand it placing it on the Pre-Enrolled sheet but how is it changing the variable it is pulling from Archive (as listed in the log) to Pre-Enrolled which is being written in the sheet?
I have written alot of If/Then else code before and have never had this issue so I am sure it is something I am missing, but I just can't seem to figure it out!
Thanks for any help you can provide!