Discussions

 View Only
Expand all | Collapse all

multiple jquery calls - first is working but the two following aren't pulling full data

  • 1.  multiple jquery calls - first is working but the two following aren't pulling full data

    Posted 12-14-2020 12:52
    Good Morning,

       I'm hoping someone can shed some light on the issue I'm encountering with the lack of return data from QB resulting from a 'jquery' call.

    The first call does great, the full list of Work Orders are pulled, the problem is the second and third calls....
    Any assistance in resolving this would be greatly appreciated.

    function fn_gp_actual_costs_update(parms1)
                    {
    
                        var grittex = fn_new_gritter('Please wait', 'Retrieving Great Plains Actual Costs for work order ' + parms1.wko);
                        var thread = $.Deferred();
    
                        cnt_pulled += 1;
                        
                        /**
                         * QB->Dev table - bqxyg2tuf (Udate fields to the new Work Order Actual Costs table (QB Dev)
                         * Retrieve QB record id# for this workorder; 
                         * this ajax call returns:
                         * 
                         *      1) Record ID#, 
                         *      2) Work Order #, and 
                         *      3) Fieldpoint WO# (if different)
                         *      4) valid?
                         *      
                         * for the 'wko' (work order #) passed to it; note the 
                         * "valid?" field identifies work orders that are licit
                         * for updating in QuickBase (i.e., those that are NOT 
                         * "valid?" are those work order #'s that also have a
                         * "Fieldpoint WO# (if different)" value.
                         */
                        
                        /** Note: This scenario may have to be altered where Work Orders with both are valid **/
                        $.getJSON('/code/get_qb_workorder_rid_ac_dev_sgl.php', parms1, function (json1)
                        {
                           
                            
                                /**
                                * Accept only the licit (i.e., "valid?" = true) work order #'s
                                * See above section
                                */
                               if (typeof (json1[0]) !== 'undefined' && typeof (json1[0]['valid?']) !== 'undefined' && json1[0]['valid?'] == true)
                               {
                                  
                                        cnt_passed += 1;
    
                                        var parms2 =
                                        {
                                            'rid': json1[0]['Record ID#'],
                                            'wko': json1[0]['Work Order # (New)'],
                                            'fwo': json1[0]['Fieldpoint WO# (if different)'],
                                            'tms': new Date().getTime() / 100
                                        };
    
                                        /** for debug purposes **/
                                        alert('parms2 - just prior to /data/spr_gp_actual_costs_update_ac_dev_sgl.php');
                                        dump(parms2); 
                                        
                
                                            /**
                                             * get updated values from SQL Server
                                             */
                                            /** 10/28/20 - Earl - Updated to reflect singular code **/
                                  
                                            $.getJSON('/data/spr_qb_actual_costs_update_ac_dev_sgl.php', parms2, function (json2)
                                            {
                                                dump(json2)
    
    
                                                    if (json2.length > 0)
                                                    {
    
                                                                /** 12/01/20 - Earl - Added 'GP_ID' to list of parameters to avoid pulling duplicate data - ln 319 **/
                                                                var parms3 =
                                                                {
                                                                    'rid': json1[0]['Record ID#'],
                                                                    'gp_id': json2[0]['GP_ID'],
                                                                    'wko': json1[0]['Work Order # (New)'],
                                                                    'fwo': json1[0]['Fieldpoint WO# (if different)'],
                                                                    'cost_code': json2[0]['Cost Code'],
                                                                    'line_item': json2[0]['Line Item'],
                                                                    'vendr': json2[0]['Vendor Name'],
                                                                    'gl_date': json2[0]['Date'],
                                                                    'desc': json2[0]['Description'],
                                                                    'docmnt': json2[0]['Document'],
                                                                    'line_item_price': json2[0]['Line Item Price']
                                                                }; 
    
                                                                dump(parms3);
                                                                
                                                                $.each(json1, function (key, value)
                                                                {
    
                                                                    /** For debug purposes **/
                                                                    alert('parms3-just prior to upl_gp_actual_costs_update_ac_dev_sgl');
                                                                    dump(parms2);
                                                                   $.getJSON('/code/upl_qb_actual_costs_update_ac_dev_sgl.php', parms3, function (json3) 
                                                                    { 
    
    
                                                                            /** 08/13/20 - Earl - Added for testing && json3.length > 0 **/
                                                                            if (typeof json3[0] !== 'undefined' && json3.length > 0)
                                                                            {
    
                                                                                 if (json3[0]['errcode'] === '0')
                                                                                 {
                                                                                     dump(json3);
                                                                                     cnt_loaded += 1;
                                                                                     fn_replace_gritter(grittex, 'Updated', 'Actual costs update complete for Work Order ' + parms2.wko + '.', 'fa-calendar-plus', false, false);
                                                                                 }
    
                                                                             } else
                                                                             {
                                                                                 cnt_errors += 1;
                                                                                 fn_replace_gritter(grittex, 'Update Error', 'Actual costs updatable could not be processed for Work Order ' + parms2.wko + '.', 'fa-calendar-minus', false, false);
                                                                             }
    
    
                                                                        thread.resolve();
                                                                    });  
                                                                });
    
    
                                                    } else 
                                                    {
                                                        cnt_errors += 1;
                                                        fn_replace_gritter(grittex, 'Update Error', 'Error updating actual costs for Work Order ' + parms2.wko + '.', 'fa-calendar-minus', false, false);
                                                        thread.resolve();
                                                    }
                                            });
                                        
                                        
                               } else
                               { 
    
                                   var mia = 
                                   {
                                       /** 08/07/20 - Earl - Changed from parm2 due to a Type Of Error **/
                                      'Work Order': parms1.wko,
                                       'Fieldpoint WO': parms1.fwo,
                                       'Record ID#': parms1.rid
                                   };
                                   absent.push(mia);
                                   cnt_absent += 1;
                                   fn_replace_gritter(grittex, 'Update Absent', 'No actual cost update found for Work Order ' + parms1.wko + '.', 'fa-calendar-minus', false, false);
                                   thread.resolve();
                               } 
                             
    
                           });
                           return thread.promise();
                       }​


    ------------------------------
    Earl Adkins
    ------------------------------


  • 2.  RE: multiple jquery calls - first is working but the two following aren't pulling full data

    Posted 12-15-2020 13:49
    That's difficult to say since all of the integration with Quick Base is obfuscated by those calls to your PHP files.  I'd suggest testing that your PHP endpoints give you the properly formatted JSON response you expect and then continue debugging from there.

    ------------------------------
    Nathan Hawe
    ------------------------------