5 Replies Latest reply on Oct 15, 2015 7:30 PM by urs h.

    How to switch off validation of a field using guidebridge?

    urs h. Level 1

      In an adaptive form I want to hide fields that are not relevant anymore because of values in other fields.

      Example: In the country I live children have a legal representative until they're grown up. If on a form somebody enters a birth date which indicates that he's older than 18 years the field demanding the name of his legal representative becomes obsolete. Such a feature is what I understand by adaptive form!

      The only way I've found so far to accomplish this is :

      * do not use the mandatory flag (because a field is always mandatory even if it's not visible)

      * check in field's validation expression whether it is visible at all: if it is visible check its value else validation expression returns true

      What I would like is a way to switch validation off by guidebridge in a elementVisibleChanged event. Is this possible? (The guidebridge documentation is deceptively incomplete for such questions.)

      Thank you,

      Urs Hofmänner

      • 0. Re: How to switch off validation of a field using guidebridge?
        urs h. Level 1

        In the visible expression (of the depending field)

        Because it's a fields responsibility to know whether it's obsolete or not.

        Better explained by the example: 
        I want that the 'legal representative' field "knows" whether it's relevant or not and not that the 'birth date' field must update all other fields if the age is greater than 18.

          • 1. Re: How to switch off validation of a field using guidebridge?
            varundua Level 1

            Also jsonModel property is internal and you should directly use 

            data.target.somExpression

            data.newText

            • 2. Re: How to switch off validation of a field using guidebridge?
              varundua Level 1

              Hi Urs,


              May I know how you are hiding the field ? Are you using the Visible Expression or the Value Commit Expression. In your use case using Value Commit Expression will give better performance.

              Regards
              Varun

              • 3. Re: How to switch off validation of a field using guidebridge?
                urs h. Level 1

                Hi Varun 

                thanks a lot for your response.

                I didn't know the field's validationsDisabled property.

                I'm using in a generic way:

                window.addEventListener("bridgeInitializeStart", function(event) { var gb = event.detail.guideBridge; gb.connect(function() { gb.on('elementVisibleChanged', function(event, data) { var widget = guideBridge .resolveNode(data.jsonModel.target.somExpression); if (widget.className == 'guidePanel' || widget.className == 'guideTextDraw') { return undefined; } if (data.jsonModel.newText) { widget.validationsDisabled = false; } else { widget.validationsDisabled = true; } }); }); });

                With this code I can enable/disable validation depending on its visibility.

                Regards,

                Urs

                • 4. Re: How to switch off validation of a field using guidebridge?
                  varundua Level 1

                  Hi 

                  You can use the validationsDisabled property of a Field to switch off validations. In your example, you can write in the value commit expression of the birthdate field 
                   

                  if ( checkIsabove18 ) { // replace checkIsAbove18 with an actual check
                      legalRepresentation.visible = false; // assuming the name of the legal representation field is legalRepresentation. If not change this with the actual name
                      legalRepresentation.validationsDisabled = true;
                  } else {
                     legalRepresentation.visible = true;

                     legalRepresentation.validationsDisabled = false;

                  }

                  Hopefully it solves your problem.

                  Happy to Help
                  Varun Dua