Home › Forums › Classic DFFS › Getting Total from vLookup
- This topic has 5 replies, 2 voices, and was last updated 7 years, 5 months ago by Todd Ingersoll.
-
AuthorPosts
-
-
June 27, 2017 at 21:03 #17022
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:
-
June 28, 2017 at 14:44 #17037
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.
- This reply was modified 7 years, 6 months ago by Todd Ingersoll.
- This reply was modified 7 years, 6 months ago by Todd Ingersoll.
-
June 29, 2017 at 21:03 #17080
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
-
July 3, 2017 at 12:28 #17143
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); } }
-
-
July 3, 2017 at 23:25 #17168
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
-
July 5, 2017 at 20:35 #17187
This worked like a charm exactly as you described. I just hadn’t thought about getFieldValue().
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.