8 Replies Latest reply on May 29, 2017 10:36 PM by Kaspi

    Error in Dynamic Window Calculation

    Kaspi Rookie

      Hello everybody!

      I have a problem with window calculation. The logic is that when you click the checkbox, the "Сервис" and "Причина" fields should hide and become optional. The same should happen with a checkbox if the "Сервис" or "Причина" field is not empty

      This is a calculation, the result of this is displayed at the bottom of the window. "Сервис" is a _Category1, "Причина" is a _ByReason and checkbox is a CauseNotFound

      Text of calculation:

      import System

      static def GetAttributeValue(Resolution):

        if Resolution._CauseNotFound:

          Value = ":SetHidden(_Category1, True);:SetHidden(_ByReason, True);:SetMandatory(_Category1, False);:SetMandatory(_ByReason, False);"

        else:

          if Resolution._Category1 is not null or Resolution._ByReason is not null:

            Value = ":SetHidden(_CauseNotFound, True);"

          else:

            Value = ":SetHidden(_Category1, False);:SetHidden(_ByReason, False);:SetHidden(_CauseNotFound, False);"

        return Value

       

      The problem is that if the "Сервис" field is first filled in and then cleared, then, if you mark checkbox, an error appears that the "Сервис" field should be filled, although the result of the calculation indicates the opposite.

      If you do one thing, that is, immediately mark checkbox or fill in the "Сервис" and "Причина" fields, then there are no problems.

      I have already tried many things, I do not know the reason.

        • 1. Re: Error in Dynamic Window Calculation
          JulianWigman Expert

          Whilst I don't understand and of the foreign language text what I think may be wrong is the case of the TRUE and FALSE.

           

          Try changing the True/False  assignments to true/false (i.e. remove the capital letter).

           

          Ju

          • 2. Re: Error in Dynamic Window Calculation
            Kaspi Rookie

            I tried to change it, but it did not help. The calculation works if you immediately fill in either the first two listboxes or the checkbox. But for some reason it does not work if you first fill in the "Сервис" field, then clear it, and then put the checkbox. That is, the logic is such that the user fills in either two leafboxes or a checkbox.

            I think that this is some kind of bug.

            • 3. Re: Error in Dynamic Window Calculation
              JulianWigman Expert

              Have you got "Is Calculate on Change" property of each field setup for the window you are using?

              • 4. Re: Error in Dynamic Window Calculation
                Kaspi Rookie

                Yes, in all three fields, this property is set. The second screenshot shows that the SetMandatory property for the field "_Category1" has the value "False", but still there is an error that it needs to be filled. And, as I wrote above, the problem is only with certain actions.

                • 5. Re: Error in Dynamic Window Calculation
                  agkale SupportEmployee

                  Hi,

                  Maybe try as per standard to return your Value functions at the end of calculation?

                   

                  import System

                  static def GetAttributeValue(Resolution):

                      

                       CategoryValueHidden= false

                       ByReasonValueHidden=false

                       CategoryMandatory= false

                       ByReasonMandatory=false

                       CauseNotFound =false

                   

                    if Resolution._CauseNotFound:

                      CategoryValueHidden= true

                       ByReasonValueHidden=true

                       CategoryMandatory= false

                       ByReason Mandatory=false

                    else:

                      if Resolution._Category1 is not null or Resolution._ByReason is not null:

                        CauseNotFound= true

                      else:

                        CategoryValueHidden= false

                         ByReasonValueHidden=false

                        CauseNotFound =false

                   

                  return ":SetHidden(_Category1, CategoryValueHidden);:SetHidden(_ByReason, ByReasonValueHidden);:SetMandatory(_Category1, CategoryMandatory);:SetMandatory(_ByReason, ByReasonMandatory);:SetHidden(_CauseNotFound, CauseNotFound);"

                   

                  Cheers,

                   

                  Agata

                   

                  • 6. Re: Error in Dynamic Window Calculation
                    JulianWigman Expert

                    Assuming the "if Resolution._CauseNotFound:" is in fact testing a Boolean attribute then I suspect the value is to do with the tri-state default nature of a Boolean;  it can be null, true or false (so 3 states).   At the start the Boolean is null until you either tick (set "true") or tick and untick again (set "false").  So this "if" statement line when initially testing is when the Boolean is null and thus it automatically goes to the ELSE part;  I think you just want the ELSE part to cater for the FALSE state of the checkbox right?

                     

                    If so make sure the DEFAULT VALUE property of this Boolean attribute is set to FALSE in object designers as I suspect this is the real issue here.  NULL checking in BOO calculations is always one to watch!

                     

                    Ju

                    • 7. Re: Error in Dynamic Window Calculation
                      Kaspi Rookie

                      Yes, I also tried it. The problem is the same.

                      • 8. Re: Error in Dynamic Window Calculation
                        Kaspi Rookie

                        Yes, the "_CauseNotFound" attribute of type boolean. But I have it in the object designer as mandatory and with a default value of FALSE.