Form Rules2

Home Forums General discussion Form Rules2

Viewing 3 reply threads
  • Author
    Posts
    • #28337
      Silvestre Kassoka
      Participant

        Hi Alex,

        I wrote the below code to calculate a Total Value in the display form .However
        when the rule executes it give the error , c.appendChild is not a function.See my code below and the respective screen shots.I am also not sure if my var total will give me the total.

        function total() {

        var t1 = getFieldValue(“zpts”);
        var t2 = getFieldValue(“p0h8”);
        var t3 = getFieldValue(“_x006f_en6”);
        console.log(t1)
        console.log(t2)
        console.log(t3)

        var total = t1 + t2 + t3;
        console.log (total)
        SetFieldValue(“h4hm”,total) ;

        }

        Thank you

      • #28339
        Alexander Bautz
        Keymaster

          There are a few errors here. Firstly you are using the wrong function – setFieldValue is written with a lower case s. If you write it with a capital S it will trigger another builtin SharePoint function.

          Secondly you cannot use setFieldValue in DispForm at all because there are no input fields to set. If you want to show the value in the place of the field “h4hm” you must replace the HTML of that field like this:

          jQuery("#dffs_h4hm .ms-formbody").html(total);

          Alexander

        • #28350
          Silvestre Kassoka
          Participant

            Hi Alexander ,

            Thanks for the code worked like a charm.

            In the end i had to edit my code to make calculations.Here goes,

            function total1() {

            var t1 = getFieldValue(“zpts”);
            var t2 = getFieldValue(“p0h8”);
            var t3 = getFieldValue(“_x006f_en6”);
            console.log(t1)
            console.log(t2)
            console.log(t3)

            var total = (parseFloat(t1) + parseFloat (t2) + parseFloat (t3));
            console.log (total)
            jQuery(“#dffs_h4hm .ms-formbody”).html(total);
            }

          • #28354
            Alexander Bautz
            Keymaster

              I’m glad you figured it out.

              Alexander

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