1
0
-1

Hi experts,

I'm currently having some issues showing or hiding sections if a calculated field is greater than a certain amount.

I have tried using the regex value in the field value of the visibility control of the section that I want to show or hide, but it didn't seem to work. 

any advise or some solution on getting this to work. 

Thank you in advance.

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      Hi
      You can write a small jquery script that stores the following values in a hidden field (lets say result) based on your calcualtion field:

      result =

      1 if greater than amount

      2 if less than amount

      3 if equal


      Using result field you can apply section visibility

      1. hironori hasegawa

        Hi Anas Misbah Shami

        Do you have any sample jQuery?

        I have tried adding the data validation in the Total USD calculated field as per below:

        <script>
        $(document).ready(function() {
            // Ensure the script runs after the form is fully loaded
            FormUtil.onReady(function() {
                // Initially hide the section
                $('#ADSection').hide();
        
                // Function to show or hide section based on calculation field value
                function checkCalcField() {
                    var calcValue = parseFloat($('#gtotalCur').val().replace(/,/g, '')); // Parse the input value and remove commas
        
                    if (calcValue > 10000) {
                        // Show the section if value is greater than 10,000
                        $('#ADSection').show();
                    } else {
                        // Hide the section if value is less than or equal to 10,000
                        $('#ADSection').hide();
                    }
                }
        
                // Listen for changes in the calculation field
                $('#gtotalCur').on('change keyup', function() {
                    checkCalcField();
                });
        
                // Initial check in case the field is pre-filled
                checkCalcField();
            });
        });
        </script>
        
        

        but didn't work.  or should it be in a custom HTML?


        Thank you in advance

      2. Anas Misbah Shami

        Yes you need to add a custome HTML component and write the script in it

      3. hironori hasegawa

        Thank you; I managed to settle with the custom HTML.

      CommentAdd your comment...
    2.  
      2
      1
      0

      Hi Hironori, Can you check if you have enabled store as numeric value? instead of regex try giving the value directly using the "Greater than or equal to" Operator. Please refer the sample app attached demonstrating your usecase.

      APP_calculationField-1-20240930120703.jwa

      Hope this helps.

      1. hironori hasegawa

        Hi Varnaa,

        Thank you for your reply. 

        After viewing your sample app in the section visibility control → field value, i didn't see the "Greater than or equal to" operator.

        Joget2.png


        With your sample app I have tried adding the operator in the field value and running the application, but the show or hide also didn't seem to work.

      2. Varnaa


        The above screenshot is from Joget version 8.1.1 which now supports operators and grouping.

        Adding operator in the field value will not work as the whole string is used to compare. Can you try enabling the regex option and try ^(1\d{2}|[2-9]\d{2,}|[1-9]\d{3,})$ in the field value. Additionally you can also test and understand the regex using  https://regex101.com/.


      3. hironori hasegawa

        Hi Varnaa,

        Thank you for your reply. 

        So basically, in version 7 the only way to achieve this is to use regex? or is there a workaround?

      4. Varnaa

        I am not able to think of any other workaround sorry. If its static value like 100 then you can use non-regex option but since you have calculation field that needs to be checked for >=somevalue regex should get the job done. 

      5. hironori hasegawa

        ok thank you for your advice.

      CommentAdd your comment...