avala

Forum Replies Created

Viewing 15 posts - 31 through 45 (of 64 total)
  • Author
    Posts
  • in reply to: Sum multiple vLookup Total columns #10883
    avala
    Participant

      Thanks, Alexander. This code, combined with some currency functions, works like a dream. The last hurdle is to run this function after the vLookup tables have loaded. I’m currently calling the function from an HTML button, but I’d like to automate this if possible.

      For anyone in a similar situation:

      
      
      fields = init_fields_v2();
      
      function AggregateTotals()
      {
      //get Man hours
      var totalVDCMH= $(".vLookup_total_vLookupVDC:eq(13)").text();
      var totalProposalMH= $(".vLookup_total_vLookupProposal:eq(11)").text();
      var totalDesignMH= $(".vLookup_total_vLookupDesign:eq(17)").text();
      
      //get cost
      var totalVDCCost= $(".vLookup_total_vLookupVDC:eq(14)").text();
      var totalProposalCost= $(".vLookup_total_vLookupProposal:eq(12)").text();
      var totalDesignCost= $(".vLookup_total_vLookupDesign:eq(18)").text();
      
      //calculate totals
      var totalMH= (+totalVDCMH+ +totalProposalMH+ +totalDesignMH);
      
      var totalnewVDCCost = parseFloat(totalVDCCost.replace(/[^0-9-.]/g, ''));
      var totalnewProposalCost = parseFloat(totalProposalCost.replace(/[^0-9-.]/g, ''));
      var totalnewDesignCost = parseFloat(totalDesignCost.replace(/[^0-9-.]/g, ''));
      
      var totalCost= (totalnewVDCCost +totalnewProposalCost +totalnewDesignCost );
      
      function CurrencyFormatted(amount)
      {
      	var i = parseFloat(amount);
      	if(isNaN(i)) { i = 0.00; }
      	var minus = '';
      	if(i < 0) { minus = '-'; }
      	i = Math.abs(i);
      	i = parseInt((i + .005) * 100);
      	i = i / 100;
      	s = new String(i);
      	if(s.indexOf('.') < 0) { s += '.00'; }
      	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
      	s = minus + s;
      	return s;
      }
      
      function CommaFormatted(amount)
      {
      	var delimiter = ","; // replace comma if desired
      	var a = amount.split('.',2)
      	var d = a[1];
      	var i = parseInt(a[0]);
      	if(isNaN(i)) { return ''; }
      	var minus = '';
      	if(i < 0) { minus = '-'; }
      	i = Math.abs(i);
      	var n = new String(i);
      	var a = [];
      	while(n.length > 3)
      	{
      		var nn = n.substr(n.length-3);
      		a.unshift(nn);
      		n = n.substr(0,n.length-3);
      	}
      	if(n.length > 0) { a.unshift(n); }
      	n = a.join(delimiter);
      	if(d.length < 1) { amount = n; }
      	else { amount = n + '.' + d; }
      	amount = minus + amount;
      	return amount;
      }
      
      var result = CurrencyFormatted(totalCost);
      result = CommaFormatted(result);
      
      setFieldValue('TotalEstimatedMHs',totalMH);
      setFieldValue('TotalEstimatedCost',"$" +result);
      
      }
      in reply to: Print function in DFFS #10508
      avala
      Participant

        That fixed it. Thanks, as always, for your help and going above and beyond. You deserve a few barrels of beer!

        in reply to: Print function in DFFS #10422
        avala
        Participant

          Sorry I missed your reply. I have updated to the most current DFFS files and I do see improvement in the spacing between the vLookup headers and items.

          Can you clarify what will and will not show up in the print out? Much of the HTML formatting in headers, horizontal lines, etcetera will show in the print preview but not in the actual printout or PDF.

          You can compare the difference in the attachments below.

          • This reply was modified 8 years, 9 months ago by avala.
          in reply to: Load parent form with folders in "open" state on load #10403
          avala
          Participant

            This is perfect! Thank you both!

            in reply to: Remove duplicate values? #10231
            avala
            Participant

              Is there a way to disable the invalid value response? We want to provide the convenience of type ahead to see if data has already been entered, but give them the opportunity to add new values to the list at the same time. Users love that autocomplete!

              Attachments:
              in reply to: Remove duplicate values? #10219
              avala
              Participant

                Works like a charm. Thank you!!!

                avala
                Participant

                  On a similar note, when you delete a child item from the “popup” window it refreshes the parent item- loosing any work you may have done. Would love to see this “fixed.”

                  in reply to: Sum action in vLookups #9788
                  avala
                  Participant

                    Bingo!
                    The correct class was vLookup_total_vLookup and not the vLookup field “Line_x0020_Total”. THANK YOU for your help on this- totally above and beyond!

                    Final code:

                    
                    
                    fields = init_fields_v2();
                    
                    function CalcTotal()
                    {
                    
                    var vLookupTotal = $(".vLookup_total_vLookup").text();
                    setFieldValue('Subtotal',vLookupTotal);
                    
                    var Subtotal = getFieldValue('Subtotal');
                    var Tax = getFieldValue('Sales_x0020_Tax');
                    var Prod = ((vLookupTotal*Tax)/100);
                    var TotalCalc = (+Prod + +vLookupTotal);
                    
                    setFieldValue('Total',TotalCalc);
                    }
                    in reply to: Sum action in vLookups #9781
                    avala
                    Participant

                      I’ve updated all DFFS files to the January 03 Beta (v4.365 BETA 1).
                      Ran the following in the Dev Console: $(“.vLookup_Line_x0020_Total_vLookup”).text(); which returned, “”

                      The function is run on the following rules:

                      Rule 1
                      If Subtotal
                      Is Changed
                      Validate on Form Load and field change
                      Run these functions: CalcTotal

                      Rule 2
                      If SalesTax
                      Is Changed
                      Validate on Form Load and field change
                      Run these functions: CalcTotal

                      It appears to be running just fine, it’s just returning an empty string. When I comment out the new subtotal var and setfield value the Total Calculations work perfectly.

                      • This reply was modified 8 years, 10 months ago by avala.
                      in reply to: Sum action in vLookups #9776
                      avala
                      Participant

                        Alexander,

                        The Subtotal field is still being cleared on function run. I’ve attempted the following:

                        1. Updated all DFFS files and plugins to December 14th, 2015 versions
                        2. Updated the following files to the January 03, 2016 BETA 1
                        DFFS_DirectToBackend.html
                        vLookup_ListView.html
                        vLookup_NewForm.html
                        SPJS-vLookup_backend.js
                        SPJS-vLookup_frontend.js
                        SPJS-vLookup_receiver.js
                        SPJS-utility.js
                        jquery.js
                        DFFS_backend_min.js
                        DFFS_frontend_min.js

                        This is my code:

                        
                        
                        fields = init_fields_v2();
                        
                        function CalcTotal()
                        {
                        
                        var vLookupTotal = $(".vLookup_Line_x0020_Total_vLookup").text();
                        setFieldValue('Subtotal',vLookupTotal);
                        
                        //var Subtotal = getFieldValue('Subtotal');
                        //var Tax = getFieldValue('Sales_x0020_Tax');
                        //var Prod = ((Subtotal*Tax)/100);
                        //var TotalCalc = (+Prod + +Subtotal);
                        //var Subtotal = getFieldValue('Subtotal');
                        
                        //setFieldValue('Total',TotalCalc);
                        }
                        • This reply was modified 8 years, 10 months ago by avala.
                        in reply to: Sum action in vLookups #9757
                        avala
                        Participant

                          No worries. I appreciate you taking the time to answer our little questions.

                          This is the code I’m currently using (I’ve commented out the rest until I can get the Subtotal working). I’ve grabbed the field internal name from the child list for Line Total (Line_x0020_Total) and used the field internal name for the vLookup (vLookup) field in the parent. Is this correct? When the function is triggered it empties the Subtotal field.

                          
                          
                          fields = init_fields_v2();
                          
                          function CalcTotal()
                          {
                          
                          var vLookupTotal = $(".vLookup_Line_x0020_Total_vLookup").text();
                          //var Subtotal = getFieldValue('Subtotal');
                          //var Tax = getFieldValue('Sales_x0020_Tax');
                          //var Prod = ((Subtotal*Tax)/100);
                          //var TotalCalc = (+Prod + +Subtotal);
                          
                          setFieldValue('Subtotal',vLookupTotal);
                          //setFieldValue('Total',TotalCalc);
                          }
                          in reply to: Update Requests for Add Folder feature in vLookup #9688
                          avala
                          Participant

                            So issue number 3 was a metadata issue. vLookup was doing it’s job just fine!

                            in reply to: Sum action in vLookups #9674
                            avala
                            Participant

                              As a quick follow up, this is the custom JS I’m using in the form. I’d like to populate the Subtotal field with the Sum from the Line Total Column in the vLookup attachment (see post attachment above).

                              
                              
                              fields = init_fields_v2();
                              
                              function CalcTotal()
                              {
                              
                              var Subtotal = getFieldValue('Subtotal');
                              var Tax = getFieldValue('Sales_x0020_Tax');
                              var Prod = ((Subtotal*Tax)/100);
                              var TotalCalc = (+Prod + +Subtotal);
                              
                              setFieldValue('Total',TotalCalc);
                              }
                              • This reply was modified 8 years, 11 months ago by avala.
                              in reply to: Sum action in vLookups #9670
                              avala
                              Participant

                                Alexander,

                                I’m in a similar situation where I’d like to do a calculation in the parent form from the _vLookup children totals. We have a few additional requests coming in the next month that will require a similar function. Is there a way to pull the TD.vLookupTotals while in the parent form or an alternate solution?

                                I’ve included an attachment for reference.

                                • This reply was modified 8 years, 11 months ago by avala.
                                Attachments:
                                in reply to: Combing SPJS-Lookup with Cascading Dropdowns #9431
                                avala
                                Participant

                                  You can ignore the previous post. The first dropdown and kill script work fine, but that dynamic component continues to elude me. We’ve tried using the CAML and filterValue with the fVal, but I think we’re just inserting the text fVal.

                                  Current config for second dropdown (using what Alexander listed above):

                                  
                                  
                                  spjs.lookup.init({
                                  	"fieldToConvertToDropdown":["Location"],	
                                  	"listName":"Task Forces",
                                  	"listBaseUrl":"/Sites/XXXXXXX",
                                  	"optTextFieldInternalName":"DefaultLocation",
                                  	"sortFieldName":"DefaultLocation",
                                  	"filterObj":{
                                  		"on":true,
                                  		"folder":"", // Leave empty to search in all folders
                                  		"CAML":"<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>[currentItem:fVal]</Value></Eq></Where>", // If used, the rest of the filterObj settings are disregarded
                                  		"fin":"Title",
                                  		"isLookup":false,
                                  		"operator":"Eq",
                                  		"filterVal":"fVal",
                                  	},
                                  	"dropDownDefaultvalue":"...",
                                  	"addYouOwnValue":{
                                  		"on":true,
                                  		"linkText":"Enter a temporary location"
                                  	},
                                  	"addToExternalList":{
                                  		"on":false,
                                  		"customFunction":null, // Function name as a string. If a function name is supplied, this will be used in stead of the default function. The function will be passed the argument object as a parameter.
                                  		"linkText":"Add new item",
                                  		"saveNewItemText":"Save new item"
                                  	},
                                  	"debug":false
                                  });
                                Viewing 15 posts - 31 through 45 (of 64 total)