Question

Refresh section on Backspace key action

We have a requirement to refresh the section on the backspace keyboard key. Can somebody help me how it implement it? Thanks in advance.

Comments

Keep up to date on this post and subscribe to comments

October 4, 2019 - 3:58pm

You could create some custom JS here to add an event listener for keydown events, then check if it was for a backspace. Once you fall into that block you could call reloadsection.

Pega
October 15, 2019 - 12:16am

Hi,

I tried the following steps (might be a little elaborate):

> For any control in the section add a keyboard event - any key and use a Run Script action. This script can be included in UserWorkForm.

> In the script, check if event.keyCode = 8 (this is the key code for backspace button). If true, call the OOTB ReloadSection activity.

Do check this link for some additional info: https://css-tricks.com/snippets/javascript/javascript-keycodes/

Hope this helps.

Thanks

Pega
October 16, 2019 - 6:39am

Hi ,

Could you confirm on the requirement,

1.Through out the application , when you click on backspace do you want the section to be refreshed or

2.is it specific to any control like on a link or on a button when you click on backspace you want it to be refreshed.

For first approach , either in userWorkForm or in harnesslevel js , custom script needs to be included as below 

<script>
  document.addEventListener("keydown", checkbackSpace); 
  function checkbackSpace(event){
    if (event.keyCode == 8) {
      alert("in the function");
      pega.u.d.refreshSection("SectionName");
    }
  }

</script>

For the second case you can write a runscript action as shown below ,pass javascript:event as value and use the same function ,place the below code in userWorkForm.

<script>
 
  function checkbackSpace(event){
    if (event.keyCode == 8) {
      alert("in the function");
      pega.u.d.refreshSection("SectionName");
    }
  }

</script>

 

October 17, 2019 - 1:53pm
Response to bathb

Thank you Bhavana, it should work. thank you!