Share This:

This is my first solution integrating BMC Remedy 9.x and Javascript.

 

This post is dedicated to my new friend (more than a brother) that gives me the challenge, praveen kumar

Now I will demonstrate how JavaScript can be used to enhance the user experience on AR System forms.

 

Special thanks to Iron Maiden, gave me reassurance and empathy with the task. lol

 

The Javascript I am designing is intended to change the focus of the field when its length is reached.

 

 

  1. First Step

Create a regular form (in my case) and the Fields

I put it on the form three char fields

 

 

The properties of the fields that matter to us are: length and ID.

 

  • Field 1
    • ID: 700000000
    • Length: 3


  • Field  2
    • ID: 700000001
    • Length: 3



  • Field  3
    • ID: 700000002
    • Length: 4

 

Once you have created the form with your fields, let's work on the javascript.

So, as I said at the top, the script should change focus when it reaches the maxlength of each field.

 

So, how does the js works?

 

In your form, open Property > Appearance (double-click the form or keep the tabs open)

 

Open the Web Header Content property and write your code (below you can see my code)

Here is the magic

 

<script language = "javascript" type = "text/javascript">
     function moveOnMax(field, fieldlenght, nextFieldID) {
          if (field.length >= fieldlenght){
          nextFieldID.focus();
          }
     }
</script>

 

Now, lets create our active links that calls the js on execution time.


So, we have 3 fields and I need to change focus from the first to the second and the second to the third, I will create two active links for these tasks.

 

The first active link

 

Permission : Public

Execution Options: Submit | Field - Gain Focus (barcat_field1)

 

If Action (here I will call the js function)

I am using a Run Process to call it. The code is below.

 

javascript document.getElementById('arid_WIN_0_700000000').onkeyup=function(){ moveOnMax(document.getElementById('arid_WIN_0_700000000').value,3,document.getElementById('arid_WIN_0_700000001'));}

 

Remember my fields ID’s? Look it here (document.getElementById('arid_WIN_0_700000000'))

 

I am passing 3 parameters to the function onkeyup

 

The value of the field

document.getElementById('arid_WIN_0_700000000').value

 

The length of the field

3

 

The next field

document.getElementById('arid_WIN_0_700000001')

 

The second active link is almost the same, just change the ID of elements.

javascript document.getElementById('arid_WIN_0_700000001').onkeyup=function(){ moveOnMax(document.getElementById('arid_WIN_0_700000001').value,3,document.getElementById('arid_WIN_0_700000002'));}