1 Reply Latest reply on Jan 3, 2017 5:00 AM by Thorsten Fleischmann

    Javascript Function in Remedy

    Kevin Kennedy
      Share:|

      Hi,

       

      I am trying to get a function working in Remedy to parse a field up as far as the last comma. e.g   name1, name2, name3 - >

      click the button once, output should be - name1, name2.

       

      I have the following in the webheader -

      <script type="text/javascript">

      function backstep("arid_WIN_0_767700031") {

      var fieldElement = document.getElementById("arid_WIN_0_767700031");

      var oldFieldValue = fieldElement.value;

      var indexOfDelimiter = fieldValue.lastIndexOf(",");

      var newFieldValue = oldFieldValue.substring(0, indexOfDelimiter);

      fieldElement.value = newFieldValue;}

      </script>

       

      I have an active link with the following

       

      javascript backstep (document.getElementById("arid_WIN_0_767700031").value);

       

      I am getting function not supported error 9369

      Looking at the console debugger - I am also getting the following -

       

      "unreachable code after return statement PopupSupport.js:1:139007

      An unbalanced tree was written using document.write() causing data from the network to be reparsed. For more information https://developer.mozilla.org/en/Optimizing_Your_Pages_for_Speculative_Parsing"

       

      Has anyone got any ideas? Thanks

       

      I believe the logic should be sound as I was able to achieve the desired affect by using a slightly edited version of this code for a simple webpage that I setup with two input boxes, where the results of the parse from the text in one would get input in a second box

        • 1. Re: Javascript Function in Remedy
          Thorsten Fleischmann

          Use that for your webHeader

          <script type="text/javascript">

           

          function backstep(inputStr) {

             var indexOfDel = inputStr.lastIndexOf(",");

             return inputStr.substring(0, indexOfDel);

          }

           

          </script>

           

          Then in your Active Link add a Set Field with

          $PROCESS$ javascript:backstep($530000001$);

           

          Change $530000001$ to the field with your text. Set it to the field where you want the output

          1 of 1 people found this helpful