Google web app server returns null even though logger.log confirms theirs data












0














I currently have a google web app that checks to see if the a value (predefined from dropdown list so it will always been in the column") is in a column, if it is, it returns information about that value. however i am trying to update it so if the value is not found in the column(user entered value), it searches a second column to see if anyone has entered that value before. the issue i am having is once it finds the user entered value, it collects the value of the cells adjacent to it and flicks it back to the client side HTML javascript, the client side is seeing it as null. It's currently working fine for the first section which uses the predefined drop down choices. it's still finding the correct information, its just the client side for some reason cannot see it. I am abit of a novice when it comes to coding so any help anyone could provide would be GREATLY appreciated.



    function sendFleet(e){ // This code sends the dropdown value to the server side
e.preventDefault();
var fleet = document.getElementById("Fleet").value
document.getElementById('photostatus').innerHTML = "Waiting For Photo.."
if(fleet != "Not on this list?"){
var data1 = {
FleetNumber: document.getElementById("Fleet").value,
}
google.script.run.withSuccessHandler(consoleyay)
.sendFleet(data1)

}
else if(fleet == "Not on this list?"){
console.log("right area")
document.getElementById("Rego").innerHTML= "Rego"
document.getElementById("NOLF").style.display=""
document.getElementById("NOLR").style.display=""
document.getElementById("NOLB").style.display=""
document.getElementById("NOLS").style.display=""
document.getElementById("Fleet").style.display="none"
document.getElementById("Rego").style.display="none"
}
}
function SENDFLEET(e){ // This code sends a user entered value to the server.
e.preventDefault();
var fleet = document.getElementById("NOLF").value
document.getElementById('photostatus').innerHTML = "Waiting For Photo.."
var data1 = {
FleetNumber: document.getElementById("NOLF").value,
}
google.script.run.withSuccessHandler(consoleyay)
.sendFleet(data1)
}

function sendFleet(data1){
var Fleet = data1.FleetNumber
var FleetListing = SpreadsheetApp.openById("1ufyN6mgzdHXoYbVC6TENcc7V2zGxdQtp0ctaCR-kiEw").getSheetByName("FleetListing")
var data2 = FleetListing.getRange(3,3,FleetListing.getLastRow(),1).getValues().reduce(function (a, b) { //flatten the 2D array obtained by .getValues()
return a.concat(b);
});;
var fleetdata = FleetListing.getRange(3,1,FleetListing.getLastRow(),8).getValues()
var Search1 = data2.indexOf(Fleet)
var site = ""
var type = ""
var fleet = ""
var rego = ""
var insidev = ""
var outsidev = ""
var insideb = ""
var outsideb = ""
var search = ""
Logger.log(Search1)
if(Search1 != "-1"){
Logger.log("shouldn't be here")
site = fleetdata[Search1][0]
type = fleetdata[Search1][1]
fleet = fleetdata[Search1][2]
rego = fleetdata[Search1][3]
insidev = fleetdata[Search1][4]
outsidev = fleetdata[Search1][5]
insideb = fleetdata[Search1][6]
outsideb = fleetdata[Search1][7]
search = Search1
}
else if(Search1 == "-1"){
var MTL = SpreadsheetApp.openById("1ufyN6mgzdHXoYbVC6TENcc7V2zGxdQtp0ctaCR-kiEw").getSheetByName("MasterToLocal")
var data3 = MTL.getRange(1,3,MTL.getLastRow(),1).getValues().reduce(function (c, d) { //flatten the 2D array obtained by .getValues()
return c.concat(d);
});;
var fleetdata1 = MTL.getRange(1,1,MTL.getLastRow(),8).getValues()
var Search2 = data3.indexOf(Fleet)
Logger.log("lukes okay")
Logger.log(Fleet)
Logger.log(Search2)
Logger.log(data3)
if(Search2 != "-1"){
Logger.log("Test start")
site = fleetdata1[Search2][0]
Logger.log(site)
type = fleetdata1[Search2][1]

fleet = fleetdata1[Search2][2]

rego = fleetdata1[Search2][3]

insidev = fleetdata1[Search2][4]

outsidev = fleetdata1[Search2][5]

insideb = fleetdata1[Search2][6]

outsideb = fleetdata1[Search2][7]
search = Search2
Logger.log("Test Finish")
}
}
return [site,type,fleet,rego,insidev,outsidev,insideb,outsideb,search]
}

function consoleyay(details){ // this is the code that handles the response from the server.
console.log(details)
var site = document.getElementById("Site").value
console.log(site)
console.log("issues 1")
var Type = document.getElementById("Type").value
console.log("issue 2")
var fleet = details[2]
var rego = details[3]
var inv = details[4]
var outv = details[5]
console.log("before bg")
var inb = details[6]
var outb = details[7]
console.log("after BG")
var Search1 = details[8]









share|improve this question





























    0














    I currently have a google web app that checks to see if the a value (predefined from dropdown list so it will always been in the column") is in a column, if it is, it returns information about that value. however i am trying to update it so if the value is not found in the column(user entered value), it searches a second column to see if anyone has entered that value before. the issue i am having is once it finds the user entered value, it collects the value of the cells adjacent to it and flicks it back to the client side HTML javascript, the client side is seeing it as null. It's currently working fine for the first section which uses the predefined drop down choices. it's still finding the correct information, its just the client side for some reason cannot see it. I am abit of a novice when it comes to coding so any help anyone could provide would be GREATLY appreciated.



        function sendFleet(e){ // This code sends the dropdown value to the server side
    e.preventDefault();
    var fleet = document.getElementById("Fleet").value
    document.getElementById('photostatus').innerHTML = "Waiting For Photo.."
    if(fleet != "Not on this list?"){
    var data1 = {
    FleetNumber: document.getElementById("Fleet").value,
    }
    google.script.run.withSuccessHandler(consoleyay)
    .sendFleet(data1)

    }
    else if(fleet == "Not on this list?"){
    console.log("right area")
    document.getElementById("Rego").innerHTML= "Rego"
    document.getElementById("NOLF").style.display=""
    document.getElementById("NOLR").style.display=""
    document.getElementById("NOLB").style.display=""
    document.getElementById("NOLS").style.display=""
    document.getElementById("Fleet").style.display="none"
    document.getElementById("Rego").style.display="none"
    }
    }
    function SENDFLEET(e){ // This code sends a user entered value to the server.
    e.preventDefault();
    var fleet = document.getElementById("NOLF").value
    document.getElementById('photostatus').innerHTML = "Waiting For Photo.."
    var data1 = {
    FleetNumber: document.getElementById("NOLF").value,
    }
    google.script.run.withSuccessHandler(consoleyay)
    .sendFleet(data1)
    }

    function sendFleet(data1){
    var Fleet = data1.FleetNumber
    var FleetListing = SpreadsheetApp.openById("1ufyN6mgzdHXoYbVC6TENcc7V2zGxdQtp0ctaCR-kiEw").getSheetByName("FleetListing")
    var data2 = FleetListing.getRange(3,3,FleetListing.getLastRow(),1).getValues().reduce(function (a, b) { //flatten the 2D array obtained by .getValues()
    return a.concat(b);
    });;
    var fleetdata = FleetListing.getRange(3,1,FleetListing.getLastRow(),8).getValues()
    var Search1 = data2.indexOf(Fleet)
    var site = ""
    var type = ""
    var fleet = ""
    var rego = ""
    var insidev = ""
    var outsidev = ""
    var insideb = ""
    var outsideb = ""
    var search = ""
    Logger.log(Search1)
    if(Search1 != "-1"){
    Logger.log("shouldn't be here")
    site = fleetdata[Search1][0]
    type = fleetdata[Search1][1]
    fleet = fleetdata[Search1][2]
    rego = fleetdata[Search1][3]
    insidev = fleetdata[Search1][4]
    outsidev = fleetdata[Search1][5]
    insideb = fleetdata[Search1][6]
    outsideb = fleetdata[Search1][7]
    search = Search1
    }
    else if(Search1 == "-1"){
    var MTL = SpreadsheetApp.openById("1ufyN6mgzdHXoYbVC6TENcc7V2zGxdQtp0ctaCR-kiEw").getSheetByName("MasterToLocal")
    var data3 = MTL.getRange(1,3,MTL.getLastRow(),1).getValues().reduce(function (c, d) { //flatten the 2D array obtained by .getValues()
    return c.concat(d);
    });;
    var fleetdata1 = MTL.getRange(1,1,MTL.getLastRow(),8).getValues()
    var Search2 = data3.indexOf(Fleet)
    Logger.log("lukes okay")
    Logger.log(Fleet)
    Logger.log(Search2)
    Logger.log(data3)
    if(Search2 != "-1"){
    Logger.log("Test start")
    site = fleetdata1[Search2][0]
    Logger.log(site)
    type = fleetdata1[Search2][1]

    fleet = fleetdata1[Search2][2]

    rego = fleetdata1[Search2][3]

    insidev = fleetdata1[Search2][4]

    outsidev = fleetdata1[Search2][5]

    insideb = fleetdata1[Search2][6]

    outsideb = fleetdata1[Search2][7]
    search = Search2
    Logger.log("Test Finish")
    }
    }
    return [site,type,fleet,rego,insidev,outsidev,insideb,outsideb,search]
    }

    function consoleyay(details){ // this is the code that handles the response from the server.
    console.log(details)
    var site = document.getElementById("Site").value
    console.log(site)
    console.log("issues 1")
    var Type = document.getElementById("Type").value
    console.log("issue 2")
    var fleet = details[2]
    var rego = details[3]
    var inv = details[4]
    var outv = details[5]
    console.log("before bg")
    var inb = details[6]
    var outb = details[7]
    console.log("after BG")
    var Search1 = details[8]









    share|improve this question



























      0












      0








      0







      I currently have a google web app that checks to see if the a value (predefined from dropdown list so it will always been in the column") is in a column, if it is, it returns information about that value. however i am trying to update it so if the value is not found in the column(user entered value), it searches a second column to see if anyone has entered that value before. the issue i am having is once it finds the user entered value, it collects the value of the cells adjacent to it and flicks it back to the client side HTML javascript, the client side is seeing it as null. It's currently working fine for the first section which uses the predefined drop down choices. it's still finding the correct information, its just the client side for some reason cannot see it. I am abit of a novice when it comes to coding so any help anyone could provide would be GREATLY appreciated.



          function sendFleet(e){ // This code sends the dropdown value to the server side
      e.preventDefault();
      var fleet = document.getElementById("Fleet").value
      document.getElementById('photostatus').innerHTML = "Waiting For Photo.."
      if(fleet != "Not on this list?"){
      var data1 = {
      FleetNumber: document.getElementById("Fleet").value,
      }
      google.script.run.withSuccessHandler(consoleyay)
      .sendFleet(data1)

      }
      else if(fleet == "Not on this list?"){
      console.log("right area")
      document.getElementById("Rego").innerHTML= "Rego"
      document.getElementById("NOLF").style.display=""
      document.getElementById("NOLR").style.display=""
      document.getElementById("NOLB").style.display=""
      document.getElementById("NOLS").style.display=""
      document.getElementById("Fleet").style.display="none"
      document.getElementById("Rego").style.display="none"
      }
      }
      function SENDFLEET(e){ // This code sends a user entered value to the server.
      e.preventDefault();
      var fleet = document.getElementById("NOLF").value
      document.getElementById('photostatus').innerHTML = "Waiting For Photo.."
      var data1 = {
      FleetNumber: document.getElementById("NOLF").value,
      }
      google.script.run.withSuccessHandler(consoleyay)
      .sendFleet(data1)
      }

      function sendFleet(data1){
      var Fleet = data1.FleetNumber
      var FleetListing = SpreadsheetApp.openById("1ufyN6mgzdHXoYbVC6TENcc7V2zGxdQtp0ctaCR-kiEw").getSheetByName("FleetListing")
      var data2 = FleetListing.getRange(3,3,FleetListing.getLastRow(),1).getValues().reduce(function (a, b) { //flatten the 2D array obtained by .getValues()
      return a.concat(b);
      });;
      var fleetdata = FleetListing.getRange(3,1,FleetListing.getLastRow(),8).getValues()
      var Search1 = data2.indexOf(Fleet)
      var site = ""
      var type = ""
      var fleet = ""
      var rego = ""
      var insidev = ""
      var outsidev = ""
      var insideb = ""
      var outsideb = ""
      var search = ""
      Logger.log(Search1)
      if(Search1 != "-1"){
      Logger.log("shouldn't be here")
      site = fleetdata[Search1][0]
      type = fleetdata[Search1][1]
      fleet = fleetdata[Search1][2]
      rego = fleetdata[Search1][3]
      insidev = fleetdata[Search1][4]
      outsidev = fleetdata[Search1][5]
      insideb = fleetdata[Search1][6]
      outsideb = fleetdata[Search1][7]
      search = Search1
      }
      else if(Search1 == "-1"){
      var MTL = SpreadsheetApp.openById("1ufyN6mgzdHXoYbVC6TENcc7V2zGxdQtp0ctaCR-kiEw").getSheetByName("MasterToLocal")
      var data3 = MTL.getRange(1,3,MTL.getLastRow(),1).getValues().reduce(function (c, d) { //flatten the 2D array obtained by .getValues()
      return c.concat(d);
      });;
      var fleetdata1 = MTL.getRange(1,1,MTL.getLastRow(),8).getValues()
      var Search2 = data3.indexOf(Fleet)
      Logger.log("lukes okay")
      Logger.log(Fleet)
      Logger.log(Search2)
      Logger.log(data3)
      if(Search2 != "-1"){
      Logger.log("Test start")
      site = fleetdata1[Search2][0]
      Logger.log(site)
      type = fleetdata1[Search2][1]

      fleet = fleetdata1[Search2][2]

      rego = fleetdata1[Search2][3]

      insidev = fleetdata1[Search2][4]

      outsidev = fleetdata1[Search2][5]

      insideb = fleetdata1[Search2][6]

      outsideb = fleetdata1[Search2][7]
      search = Search2
      Logger.log("Test Finish")
      }
      }
      return [site,type,fleet,rego,insidev,outsidev,insideb,outsideb,search]
      }

      function consoleyay(details){ // this is the code that handles the response from the server.
      console.log(details)
      var site = document.getElementById("Site").value
      console.log(site)
      console.log("issues 1")
      var Type = document.getElementById("Type").value
      console.log("issue 2")
      var fleet = details[2]
      var rego = details[3]
      var inv = details[4]
      var outv = details[5]
      console.log("before bg")
      var inb = details[6]
      var outb = details[7]
      console.log("after BG")
      var Search1 = details[8]









      share|improve this question















      I currently have a google web app that checks to see if the a value (predefined from dropdown list so it will always been in the column") is in a column, if it is, it returns information about that value. however i am trying to update it so if the value is not found in the column(user entered value), it searches a second column to see if anyone has entered that value before. the issue i am having is once it finds the user entered value, it collects the value of the cells adjacent to it and flicks it back to the client side HTML javascript, the client side is seeing it as null. It's currently working fine for the first section which uses the predefined drop down choices. it's still finding the correct information, its just the client side for some reason cannot see it. I am abit of a novice when it comes to coding so any help anyone could provide would be GREATLY appreciated.



          function sendFleet(e){ // This code sends the dropdown value to the server side
      e.preventDefault();
      var fleet = document.getElementById("Fleet").value
      document.getElementById('photostatus').innerHTML = "Waiting For Photo.."
      if(fleet != "Not on this list?"){
      var data1 = {
      FleetNumber: document.getElementById("Fleet").value,
      }
      google.script.run.withSuccessHandler(consoleyay)
      .sendFleet(data1)

      }
      else if(fleet == "Not on this list?"){
      console.log("right area")
      document.getElementById("Rego").innerHTML= "Rego"
      document.getElementById("NOLF").style.display=""
      document.getElementById("NOLR").style.display=""
      document.getElementById("NOLB").style.display=""
      document.getElementById("NOLS").style.display=""
      document.getElementById("Fleet").style.display="none"
      document.getElementById("Rego").style.display="none"
      }
      }
      function SENDFLEET(e){ // This code sends a user entered value to the server.
      e.preventDefault();
      var fleet = document.getElementById("NOLF").value
      document.getElementById('photostatus').innerHTML = "Waiting For Photo.."
      var data1 = {
      FleetNumber: document.getElementById("NOLF").value,
      }
      google.script.run.withSuccessHandler(consoleyay)
      .sendFleet(data1)
      }

      function sendFleet(data1){
      var Fleet = data1.FleetNumber
      var FleetListing = SpreadsheetApp.openById("1ufyN6mgzdHXoYbVC6TENcc7V2zGxdQtp0ctaCR-kiEw").getSheetByName("FleetListing")
      var data2 = FleetListing.getRange(3,3,FleetListing.getLastRow(),1).getValues().reduce(function (a, b) { //flatten the 2D array obtained by .getValues()
      return a.concat(b);
      });;
      var fleetdata = FleetListing.getRange(3,1,FleetListing.getLastRow(),8).getValues()
      var Search1 = data2.indexOf(Fleet)
      var site = ""
      var type = ""
      var fleet = ""
      var rego = ""
      var insidev = ""
      var outsidev = ""
      var insideb = ""
      var outsideb = ""
      var search = ""
      Logger.log(Search1)
      if(Search1 != "-1"){
      Logger.log("shouldn't be here")
      site = fleetdata[Search1][0]
      type = fleetdata[Search1][1]
      fleet = fleetdata[Search1][2]
      rego = fleetdata[Search1][3]
      insidev = fleetdata[Search1][4]
      outsidev = fleetdata[Search1][5]
      insideb = fleetdata[Search1][6]
      outsideb = fleetdata[Search1][7]
      search = Search1
      }
      else if(Search1 == "-1"){
      var MTL = SpreadsheetApp.openById("1ufyN6mgzdHXoYbVC6TENcc7V2zGxdQtp0ctaCR-kiEw").getSheetByName("MasterToLocal")
      var data3 = MTL.getRange(1,3,MTL.getLastRow(),1).getValues().reduce(function (c, d) { //flatten the 2D array obtained by .getValues()
      return c.concat(d);
      });;
      var fleetdata1 = MTL.getRange(1,1,MTL.getLastRow(),8).getValues()
      var Search2 = data3.indexOf(Fleet)
      Logger.log("lukes okay")
      Logger.log(Fleet)
      Logger.log(Search2)
      Logger.log(data3)
      if(Search2 != "-1"){
      Logger.log("Test start")
      site = fleetdata1[Search2][0]
      Logger.log(site)
      type = fleetdata1[Search2][1]

      fleet = fleetdata1[Search2][2]

      rego = fleetdata1[Search2][3]

      insidev = fleetdata1[Search2][4]

      outsidev = fleetdata1[Search2][5]

      insideb = fleetdata1[Search2][6]

      outsideb = fleetdata1[Search2][7]
      search = Search2
      Logger.log("Test Finish")
      }
      }
      return [site,type,fleet,rego,insidev,outsidev,insideb,outsideb,search]
      }

      function consoleyay(details){ // this is the code that handles the response from the server.
      console.log(details)
      var site = document.getElementById("Site").value
      console.log(site)
      console.log("issues 1")
      var Type = document.getElementById("Type").value
      console.log("issue 2")
      var fleet = details[2]
      var rego = details[3]
      var inv = details[4]
      var outv = details[5]
      console.log("before bg")
      var inb = details[6]
      var outb = details[7]
      console.log("after BG")
      var Search1 = details[8]






      google-apps-script






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 at 2:55









      Dan Cornilescu

      27.5k113161




      27.5k113161










      asked Nov 20 at 0:28









      Mitchell Robertson

      132




      132
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Solved the issue. one of the values it was collecting was a date so for some reason it was coming back as null. I have just used the toString() to fix this issue.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384554%2fgoogle-web-app-server-returns-null-even-though-logger-log-confirms-theirs-data%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Solved the issue. one of the values it was collecting was a date so for some reason it was coming back as null. I have just used the toString() to fix this issue.






            share|improve this answer


























              1














              Solved the issue. one of the values it was collecting was a date so for some reason it was coming back as null. I have just used the toString() to fix this issue.






              share|improve this answer
























                1












                1








                1






                Solved the issue. one of the values it was collecting was a date so for some reason it was coming back as null. I have just used the toString() to fix this issue.






                share|improve this answer












                Solved the issue. one of the values it was collecting was a date so for some reason it was coming back as null. I have just used the toString() to fix this issue.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 20 at 3:03









                Mitchell Robertson

                132




                132






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384554%2fgoogle-web-app-server-returns-null-even-though-logger-log-confirms-theirs-data%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    Origin of the phrase “under your belt”?