1 Reply Latest reply on Feb 11, 2016 8:20 PM by DavidJondreau

    Validation in portal against parent TO

    HammerOz

      Hi there,

       

      I have a parent table (Production). The child table is (Grades). I am entering % of production for each grade in a portal. So how to best ensure the total percent of all grades is not more than 100%?

       

      • Parent production table has a calculated field cGradePercTotal  which his the sum of the child grades %.
      • A calculated validation for the grade field Grade_Percent that references the parent Production  If(Sum(PROD::cGradePercTot)<100;1;0)
      • A script trigger commits records after each grade % is updated (on object modify)

       

      Result

      When the portal first goes over 100% the validation doesn't kick in even when I change Production records. I then change the % of a grade so the total is back under 100% and the validation error kicks. I cant change % of grade to a lower value. It has to be deleted. I am watching If(Sum(PROD::cGradePercTot)<100;1;0) in the data viewer and it is providing the right boolean result.

       

      I thought validation by the field was most robust or should I script validation? Thank you!!

        • 1. Re: Validation in portal against parent TO
          DavidJondreau

          It's hard to use Validation options on a parent record against children. Validation requires a stored non-calculation field. You can use a number result with an auto-enter calculation to validate, but it won't update without some scripted intervention.


          I think you'd be better off scripting the whole thing. Probably an OnRecordCommit triggered script.