Getting Total from vLookup

Home Forums Classic DFFS Getting Total from vLookup

Viewing 3 reply threads
  • Author
    Posts
    • #17022
      Todd Ingersoll
      Participant

        Can you provide a clear step by step process to capture the Total from my vLookup call and save it as a column (‘Total Lbs’, for instance) in the parent form on Form Save?

        Attachments:
      • #17037
        Todd Ingersoll
        Participant

          I’ve seen this post: https://spjsblog.com/forums/topic/sum-multiple-vlookup-total-columns/, but just can’t seem to translate it into my simpler case. I just need some direction to help get going. I have the vLookup working just need to capture the total and save to list, should be simple I think. I will document this for other’s use as I think this is a strong use case.

        • #17080
          Alexander Bautz
          Keymaster

            If you have a relatively new vLookup version you find the total here:

            spjs.vLookup.dataObj["vLookup_YOUR_VLOOKUP_FIELD][spjs.dffs.data.thisItemID].tot["THE_FIELD_YOU_WANT_THE_TOTAL_FROM"]

            Alexander

            • #17143
              Todd Ingersoll
              Participant

                Thanks for this Alexeander, I got the edit form working with your code (code below). My vLookup field is Batches, The field I am totaling is Dried_x0020_LBs.

                You were correct in that the less modern vLookup code referenced in the other article above does not work with more recent ones, I have v2.2.84.

                Would you happen to know how I can use this on the new form when the “.thisItemID” isn’t known yet?

                
                
                //Wait until vLookup loads
                function vLookupIsLoadedCallback(fin){
                if(fin === "vLookupBatches"){
                	//Get Total Pounds from vLookup
                	var vLookupTotal = spjs.vLookup.dataObj["vLookupBatches"][spjs.dffs.data.thisItemID].tot["Dried_x0020_LBs"];
                	setFieldValue('P1pounds',vLookupTotal);
                }
                }
            • #17168
              Alexander Bautz
              Keymaster

                Try bringing up the developer tools and type in

                    spjs.vLookup.dataObj

                Hit enter, and look at the output to see how the _vLookupID column is used as ID.

                You must have the column “_vLookupID” (single line of text) in the list you are using vLookup with, and can get the value like this:

                var myID = getFieldValue("_vLookupID");
                var vLookupTotal = spjs.vLookup.dataObj["vLookupBatches"][myID].tot["Dried_x0020_LBs"];

                Alexander

                • #17187
                  Todd Ingersoll
                  Participant

                    This worked like a charm exactly as you described. I just hadn’t thought about getFieldValue().

              Viewing 3 reply threads
              • You must be logged in to reply to this topic.