Totals Row

Forums vLooup for SharePoint Totals Row

This topic contains 7 replies, has 2 voices, and was last updated by  Alexander Bautz 1 month ago.

  • Author
    Posts
  • #19367

    Hi,

    I got the option to show me the total value of all my lookup items. Is it possible to work with this totals value? e.g. use this in my form in a field.

    I have a invoice in a list. and the different items of the invoice are lookups into another list. to avoid wrong calculation I would like to use the totals row value to show the total of the invoice? does this explanation make sense?

    thanks

  • #19396

    Alexander Bautz
    Keymaster

    Hi,
    You can access the total value for a specific field like this for use in custom code:

    varMyTot = spjs.vLookup.dataObj.YOUR_vLookup_FIELD_NAME[spjs.dffs.data.thisItemID].tot.YOUR_FIELD_NAME

    Change “YOUR_vLookup_FIELD_NAME” for your vLookup field name and “YOUR_FIELD_NAME” with the field you want the total of.

    You can for example add this to your custom js to have the value from the field “PercentCompleted” in the vLookup column named “vLookupTasks” written to a field named “Test123”:

    function vLookupIsLoadedCallback(fin){
        if(fin === "vLookupTasks"){
        	setFieldValue("test123",spjs.vLookup.dataObj.vLookupTasks[spjs.dffs.data.thisItemID].tot.PercentCompleted);
        }
    }

    Alexander

  • #19416

    Hi Alexander,

    that works so far. The only issue I found is when there is only one item in the lookup. This returns no value in the totals field and therefore the test123 field stays empty.

    Is there a work around so also one item returns a totals value?

    thanks.

  • #19419

    Hi Alexander,

    I just ran into another issue. When I put the code into the JS section of the EditForm everything works well beside the issue in my previous post but today in the morning i recognized that the code is gone.

    thanks.
    Christoph

  • #19436

    Alexander Bautz
    Keymaster

    Hi,
    I cannot recreate the issue where only one item doesn’t show total – can you show me a screenshot?

    Regarding the missing code in custom js:
    I haven’t seen this happen before, but maybe there were some sort of save error?

    If you continue having the same problem, please use F12 > Console to see if you have any errors in the console while reloading the config or saving.

    Alexander

  • #19460

    Hi Alexander,

    I guess the issue with the totals row has to do with the missing code after seconds. Attached you can see two screenshots taken one after the other (see the time in the right bottom corner). the interesting part is the time when the code got save. there is one hour difference but the screenshot with no code was taken later.

    thanks.
    Christoph

  • #19470

    Hi Alexander,

    is there also a way to define when the script is executed? I guess by default it is executed on load, right? Is there any chance to run this little script on save? so when I click on save?

    thanks.

  • #19489

    Alexander Bautz
    Keymaster

    Hi,
    Maybe you had two EditForm configs open at the same time? – I have fixed an issue where you didn’t get a version conflict on save in this scenario – are you using the latest version?

    To run the code on save, use it like this:

    function dffs_PreSaveAction({
    setFieldValue("test123",spjs.vLookup.dataObj.vLookupTasks[spjs.dffs.data.thisItemID].tot.PercentCompleted);
    }

    Alexander

You must be logged in to reply to this topic.