Skip to Content
Author's profile photo Peter Spielvogel

Creating On-Enter functionality in SAP Screen Personas 3.0 scripts

One powerful feature in SAP Screen Personas 2.0 was the ability to create a script (sequence of keyboard and other actions) and attach it to a text field. After the user filled in the field, he or she could activate the script by hitting the Enter key.

We saw customers use this feature in two ways:

  1. Launch transactions: start different processes based on different input fields
  2. Form processing: validate input before triggering the next steps in a process

Scenario 1 was easy to implement in SAP Screen Personas 2.0 because you could assign a script directly to the enter event of a specific field.

Scenario 2 was cumbersome in SAP Screen Personas 2.0 because you had to assign the same script to all possible UI actions. Once you created your script button, you would need to manually attach it to every input field (using an onEnter event) and every button (using the onClick event). If you missed one field or button, the validation would not occur for that control.

onBeforeRefresh replaces onEnter

To make both scenarios easier to solve in SAP Screen Personas 3.0, we have removed the onEnter event for specific fields and introduced the onBeforeRefresh event for screen. The event is fired BEFORE a request is sent to the backend that is triggered by ANY user interaction on the screen.

Launching transactions with the Enter key

Since SAP Screen Personas 3.0 is built into Web GUI, and the Enter key generates an action attached to the screen and not a specific field, we could not provide an On-Enter event. But, there is a way to replicate the On-Enter functionality in SAP Screen Personas 3.0.


Replicating scenario 1 in SAP Screen Personas 3.0 follows three basic steps.

  1. Write your script(s) that you want attached to a text field
  2. Use the script below to trap the Enter key
  3. Attach the “On-Enter” script to the onBeforeRefesh screen event

In this example, I will use two simple scripts to which I will attach the On-Enter functionality.

“LOOKUP” takes an input from the SMEN screen and goes to transaction VA03 to retrieve the value of a sales order and displays it on the SMEN screen.

I have attached this to the Check Sales Order Button

“JUMP” takes an input from the SMEN screen and jumps directly to the main screen in VA03, bypassing the initial screen in that transaction.

This is attached to the Check Sales Order button.

The On-Enter functionality comes from a script called ON_ENTER_SETUP that is attached to the onBeforeRefresh event.


The following is a generic form of the script. You can copy this into the script window of SAP Screen Personas 3.0 and replace the TEXT_INPUT_BOX_N_ID and BUTTON_N_ID with the values you can find on your own screen using the Inspector tool that is built into the script editor.

// ignore event if not onEnter

if (triggerType !== source.EVENT_ENTER) return;

if (focused && === ‘TEXT_INPUT_BOX_1_ID’){



if (focused && === ‘TEXT_INPUT_BOX_2_ID’){



Now, when I enter a number into my Lookup Sales Order button and hit enter, the system brings back the values from VA03 with no additional keystrokes.

Form processing

With SAP Screen Personas 3.0, you can simply validate input data on the screen. If the input is valid, don’t do anything, if something is wrong, you could open a popup with more information or show/hide on screen information using sticky notes or labels. This provides the added benefit of suppressing the unnecessary request to the backend by returning any value, e.g. return true.

This is just one of many ways you can boost user productivity by personalizing screens to meet their specific needs.

For more information, please read one of our knowledge base articles.

For the SAP Screen Personas product team, Peter Spielvogel.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      That script was exactly what I was looking for. Unfortunately the script is not working for me. The Chrome debugger comes out with some kind of "focused" is not defined. Did I miss out something in your example ?

      Thx for your help.


      Author's profile photo Former Member
      Former Member

      As you probably notice - I have absolutely no clou about java script... 🙁 - but google is your friend. So I found a solution that works fine for my flavour:


      Author's profile photo Kranthi Kumar Muppala
      Kranthi Kumar Muppala

      Hi Thomas,

      The approach you used above is incorrect. The 'focused' object will be available to the scripting engine during script execution and will not work if you execute the script manually in the script editor. Ensure that you assign the script to the 'OnBeforeRefresh' screen event and test it by performing an action on the screen.



      Author's profile photo Benjamin Greulich
      Benjamin Greulich

      Is there a way with table cells? If I press enter in a cell, no script react onEnter and the way in the article don't work.

      Thanks for an idea.