Discussions

 View Only
  • 1.  Javascript Using IOL not working?

    Posted 10-30-2019 13:01
    Hello all! 
    Without making any changes to the app at all, I come in this morning and parts of my app that rely on a Javascript page are not working. I checked on a different app that uses the same code, and it is also broken there. Is anybody else having issues this morning? The code uses the IOL technique, but other parts that use that same technique are working fine....

    ------------------------------
    Amanda
    ------------------------------


  • 2.  RE: Javascript Using IOL not working?

    Posted 10-30-2019 13:34
    Alas, it looks like there was an update. 

    From QB: 
    "If your implementation includes relying on our internal libraries, those would need to be upgraded as we do not support those techniques. For the most stable and supportable Quick Base implementation, we suggest only using native or support methodologies. As a best practice to custom interfaces, developers should host, maintain and upgrade their own libraries. I believe that is what you are seeing here. The libraries have been recently updated and now your JavaScript cannot find the jQuery library that it was previously using."

    Anybody know how to update this code below to work with their updates? I wish I could use only native functions, but those seem to be lacking in several areas.
    //creates colorized rows in Sales appointments --> Sales Log  
    
    $("table.searchResults tr.ev").css({backgroundColor: "#f2f2f2"});
    
    
    
    //concatenates and adds interactions notes to the sales log 
    (function(){
    
      $("img[qbu=module]").remove();
    
      //parameters:
      var dbid = "XXXXX";
      var dbidParents = "XXXXX"; // Homeowner contact details
      var dbidChilds = "XXXXXX"; // Interactions
      var apptoken = "XXXXXXXX";
      var n = 100;
      var relatedParentFid = "6";
      var relatedParentLabel = "related_contact";
      var clist = "6.12.135.136.138";
      var slist = "1";
      var options = "sortorder-D";
      var qbuClass = "QBU_Childs";
      var template = "<ul style=list-style-type:none>{{#.}}<li><br><small><i>{{date_created}} <br>{{record_owner}}</small></i> <br>{{conversation_details}} </li>{{/.}}</ul>"; 
      
    
      $.ajaxSetup({data: {apptoken: apptoken}});
    
      var rids = $("div.QBU_Childs").map(function() {
        return this.dataset.rid;
      }).get();
    
      _.chain(rids).groupBy(function(element, index){
        return Math.floor(index/n);
      }).toArray().each(function(rids, index) {
    
        $.ajax({
          url: dbidChilds,
          data: {
            act: "API_DoQuery",
            clist: clist,
    	slist: slist,
    	options: options,
            query: ridsToQuery(rids, relatedParentFid)
          },
          dataFilter: XMLFlatToObj 
        }).then(function(resp) {
          _.chain(resp.records).groupBy(function(items) {
            return items[relatedParentLabel];
          }).each(function(item, rid) {
            var markup = Mustache.render(template, item);
            $("div." + qbuClass + "[data-rid=" + rid + "]").html(markup);
    
    
          });        
        });
    
      });  
    
      function XMLFlatToObj(xml, type) {
        var data = [];
        var record = {};
        $("record", xml).each(function() {
          record = {};
          $(this).children().each(function () {
            record[$(this).prop("tagName")] = $(this).text();
          });
          data.push(record);
        });
        return {records: data};
      }
    
      function ridsToQuery(rids, fid) {
        fid = fid || "3";
        return "{" + fid + ".EX." + rids.join("}OR{" + fid + ".EX.") + "}AND({78.EX.No Sale}OR{78.EX.Full Demo}OR{78.EX.Sold}OR{78.EX.Reload})";
      }
    
    })();
    
    
    //concatenates and adds field notes to the sales log 
    (function(){
    
      $("img[qbu=module]").remove();
    
      //parameters:
      var dbid = "XXXXXX";
      var dbidParents = "XXXXXX"; // homeowner contact details
      var dbidChilds2 = "XXXXXX"; //sales appointments
      var apptoken = "XXXXXXXXXX";
      var n = 100;
      var relatedParentFid = "14";
      var relatedParentLabel = "related_contact";
      var clist = "14.106.104.105.102.100";
      var slist = "1";
      var options = "sortorder-D";
      var qbuClass = "QBU_Childs2";
      var template = "<ul style=list-style-type:none>{{#.}}<li><i><small>{{date_modified}}<br>Appointment Date: {{appointment_date}}<br>Created by: {{record_owner}}<br></i></small>{{{field_notes}}}<br><br></li>{{/.}}</ul>";   
    
      $.ajaxSetup({data: {apptoken: apptoken}});
    
      var rids = $("div.QBU_Childs2").map(function() {
        return this.dataset.rid;
      }).get();
    
      _.chain(rids).groupBy(function(element, index){
        return Math.floor(index/n);
      }).toArray().each(function(rids, index) {
    
        $.ajax({
          url: dbidChilds2,
          data: {
            act: "API_DoQuery",
            clist: clist,
    	slist: slist,
    	options: options,
            query: ridsToQuery(rids, relatedParentFid)
          },
          dataFilter: XMLFlatToObj 
        }).then(function(resp) {
          _.chain(resp.records).groupBy(function(items) {
            return items[relatedParentLabel];
          }).each(function(item, rid) {
            var markup = Mustache.render(template, item);
            $("div." + qbuClass + "[data-rid=" + rid + "]").html(markup);
          });        
        });
    
      });  
    
      function XMLFlatToObj(xml, type) {
        var data = [];
        var record = {};
        $("record", xml).each(function() {
          record = {};
          $(this).children().each(function () {
            record[$(this).prop("tagName")] = $(this).text();
          });
          data.push(record);
        });
        return {records: data};
      }
    
      function ridsToQuery(rids, fid) {
        fid = fid || "14";
        return "{" + fid + ".EX." + rids.join("}OR{" + fid + ".EX.") + "}";
      }
    
    })();

    Here's my IOL for the second two scripts (the ones that aren't working) 
    iol
    
    <img qbu='module' src='/i/clear2x2.gif' onload="javascript:if(typeof QBU=='undefined'){QBU={};$.getScript(gReqAppDBID+'?a=dbpage&pagename=
    
    
    /iol
    &rand='+new Date().getTime())};">


    ------------------------------
    Amanda Luna
    ------------------------------



  • 3.  RE: Javascript Using IOL not working?

    Posted 10-30-2019 17:01
    It's because mustache.js is no longer in QB library. I'll try to get to this later and see if it can be loaded without conflicts to other modules.

    ------------------------------
    Everett Patterson
    ------------------------------



  • 4.  RE: Javascript Using IOL not working?

    Posted 10-30-2019 17:13
    Everett, 
    I would be SOO thankful if you could. 

    Thanks for taking the time!

    ------------------------------
    Amanda Luna
    ------------------------------