1
0
-1

Hello, Is there any way to get a substring using hash variable?

 

 

    CommentAdd your comment...

    3 answers

    1.  
      1
      0
      -1

      Hi Sebastian Alonsoabout

      Kindly download and import this sample app into your Joget Workflow, will work in both community and enterprise version 5+.

      The app has a form with example JS to substring the '#currentUser.username#' and '#date.EEEE, d MMMM yyyy' into 2 text field element. Works the same concept for form hash variable. Will also work on hidden fields too.

      The JS/Jquery code in the form sits in the CustomHTML field element, as follows:

      <script>
      $(document).ready( function(){
      var uName = '#currentUser.username#';
      var subUname = uName.substring(2, 5);
      $('#subUsername').val(subUname);
      var uDate = '#date.EEEE, d MMMM yyyy#';
      var subUdate = uDate.substring(16, 20);
      $('#subDate').val(subUdate);
      });
      </script>

      You can also use substring hash in beanshell using the Java syntax.

      APP_substrhash-sample-app.jwa

       

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi Andrew,

                         I'd just tried and I'm mising something in the writing. The next Hash Variable #form.0101_Solicitud.SubRubro# gives as result one string. How must I write the sentence in the hidden Field so as to get the first 3 chars from this string?

        Thanks in advance.

        Sebastian.

          CommentAdd your comment...
        1.  
          1
          0
          -1

          Hi Sebastian

          You can use JS String.prototype.substring() to extract a substring from a hash variable or a Java beanshell.

            CommentAdd your comment...