Skip to Content

Portal User Idle time out – NW Portal 7.4


We all know that there is no standard solution provided by SAP to log out an idle user.After a number of futile search attempts in google/SDN for a solution, I set about to find a solution on my own. Find below the steps to create the simple portal component which tracks the user inactivity.

I have already  seen couple of solutions for this but they have minor issues and did not suit my requirements.

1. Portal user idle timeout using dialog windows – Client side solution => this solution does not seem to work for AJAX Framework in recent releases and did not track the user clicks, mouse movement etc. It worked only for Navigation event in portal. Basically, it will consider the user idle if he does not navigate. The user will be timed out

2. => Though this one says that it can track the user clicks, mouse movements etc, the logoff functionality did not work in NW portal 7.4.

My requirement is to track the user events in the content area as well before deciding if the user is idle or not.

The portal component which I have developed is very basic and uses Jquery. It tracks Key press, mouse movements in content area of the portal framework.

1. Go to Development Infrastructure perspective and create a EP DC

Screen Shot 2015-07-27 at 15.48.20.png

Screen Shot 2015-07-27 at 15.50.40.png

Click finish.

2. Create a ‘Portal Application Object’ in this EP DC.

Screen Shot 2015-07-27 at 15.52.33.png

Click Next. Select the DC created in step 1

Screen Shot 2015-07-27 at 15.52.41.png

Click Next. Choose Portal Component -> JSPDynPage

Screen Shot 2015-07-27 at 15.52.58.png

Click Next.  Enter the JSP class, package and file name.

Screen Shot 2015-07-27 at 15.53.19.png

Click Finish.

3. Open the TimeOut.jsp file under dist/PORTAL-INF/pagelet folder and copy the code below. Make sure that you place the relevant Jquery file under /scripts folder.



<% String mimeUrl = componentRequest.getWebResourcePath(); %>

  <script type=“text/javascript” src=<%=mimeUrl%>/scripts/jquery-1.11.2.min.js”></script>

<script type=“text/javascript”>

var idleTime = 0;

$(document).ready(function () {

    //Increment the idle time counter every minute.

    idleInterval = setInterval(timerIncrement, 120000); // 2 minute

    //Zero the idle timer on mouse movement.

    $(‘body’).mousemove(function (e) {

     idleTime = 0;

     document.querySelector(‘.content .value’).innerHTML = idleTime + “mouse moved”;


    $(‘body’).keypress(function (e) {

        idleTime = 0;

        document.querySelector(‘.content .value’).innerHTML =idleTime +  “key press”;


    $(‘body’).click(function() {

       idleTime = 0;

       document.querySelector(‘.content .value’).innerHTML = idleTime + “mouse moved”;



function timerIncrement() {

    idleTime = idleTime + 1;

    document.querySelector(‘.content .value’).innerHTML = idleTime;

    if (idleTime > 0) {

        if (confirm(‘Your session is inactive for the last 2 minutes. Press OK to log off. Press cancel to extend the session.’) == true) {



        } else {

        idleTime = 0;

        document.querySelector(‘.content .value’).innerHTML = idleTime









<div class=“content”>Status:  <span class=‘value’></span></div>



4. Build and Deploy the DC to the server.

5. Create an iview for the deployed application. You can preview and test before embedding it in the portal framework.

  Preview the iview and do not do any action on it. You can see the pop up below after 2 minutes.

Screen Shot 2015-07-27 at 16.04.47.png

6. Now you can place this iview in the framework page under ‘Technical Hidden iviews Container’.

Screen Shot 2015-07-27 at 16.04.27.png

7. Save the Framework page. Log off and login to the portal.

As you can see, code is simple and timings and messages can be customised as per your requirements.

I have placed the following HTML element in the code so as to check if the mouse movements and user clicks are tracked or not.

<div class=“content”>Status:  <span class=‘value’></span></div>

Since you have placed the iview under hidden iviews, you will not be able to see this HTML element. If you want to debug , please move the iview to one of the other containers and make the component visible on the screen.

Feel free to comment any improvisations on this approach.

You must be Logged on to comment or reply to a post.
  • /
      • Thanks Sharadha,

        Now working fine, great work!!

        I want to apply this solution to Fiori Framework page, but if I add the iview to Fiori Framework page, nothing is displayed anymore.



        Do you have any suggestion for me?

        Thanks in advance


          • /
          • Massimo,

            can you change the browser language to english and send the log. I do not understand the error.

            Also to change the confirm pop up to alert, change the lines below.

            if (confirm('Your session is inactive for the last 2 minutes. Press OK to log off. Press cancel to extend the session.') == true) {





          • Thank you Sharadha,

            I have changed my code and I've added the Timeout iview directly in the page where I need to have a TimeOut, and now it's working fine.

            The problem is still when I add the Timeout iview in the Fiori Framework Page.

            The fiori launchpad is displayed blank,  but the time out works fine

            this is the console result, no errors are displayed:


            Thank again,

            very good work!!


  • Hi  Sharadha,

    As mentioned above i have added .js file in my project still i am getting below mentioned error.

    Please suggest.



    Thanks & Regards,

    Meghal Shah

  • Hi Sharadha,

    I have the same  idle requirement in Portal,i have followed  same your document has given  above. i have  added the Jquery file to the project under /scripts folder

    whenever deploying i am  getting some  below deployment error,please kindly Help me, this is very high priority

    Thanks in Advance



        • Hiii All,

          Is there any process to deploy direct to server,if anyone knows please tell me how clearly

          I really appreciate any help.



        • Hi Venkat ,

          1. Make a Login with sidadm on NW7.3 WebAs server.

          2. Navigate to  /usr/sap/SID/Instance<No>/j2ee/deployment/scripts

          3. locate deploy.csh (used in Unix environment) \ deploy.bat (Used on windows platform) file under scripts directory.

          4.  Execute following command to deploy .ear \ .war \ .sda files server

          ./deploy.csh  username:password@FQDN Name of server:50004 /location of file

          Thanks & Regards,

          Meghal Shah

          • Hi Meghal Shah,

            I deployed .ear file using Telnet  tool Successfully,then where i can find that .ear file application in Portal side,after finding application what process i need to follow kindly explain step by step.

            Thanks in advance Meghal



          • Dear Meghal Shah,

            Actually i am new to NWDS 7.3 so i  am unable to develop this Portal idle Time out Application,please provide any scratch document step by step,its very urgent for my Client in Production,if you provide document very helpful to me,please do needful.

            my mail id

            thanks in advance



  • Hi Sharadha,

    I'm still trying to set this application in Fiori Framework Page, but when I add the iview in the Framework page, the Landing Page is not displayed anymore, I only see the background, no menu bar, no Tiles are displayed.



    Can you help me with this?

    Thanks in advance


  • Hi Sharadha,

    I have created Ideal Timeout as per your document, but it is not tracking user events in content area in sap portal 7.4.

    Please help me on this issue? how to track user events in content area.



  • Hi Sharadha,

    Thanks for blog. It is really helpful to me as I am also working on a similar requirement on Portal 7.4.

    I tried the same steps mentioned and currently stuck with 2 issues in each browser:

    IE 11:

    1. Preview of the IView does not show any event capture and the code does not seem to work.
    2. Using the IE developer tool, I could the see the error as belowIE11_Error.jpg

    Result: Not working in IE11


    1. Preview working fine and all the events related to Keyboard & Mouse is captured and the counter is reset.
    2. Works fine when the session is left without any activity.

    However, I noticed that in spite of continuous movement of mouse and keyboard actions, the pop-up is displayed after 2 min and the Status value becomes 1.

    I tried several iterations and this was observed everytime.

    I am not much worried about the chrome browser, as the clients only use IE11 and it does not work there 🙁

    I am using the jquery-1.11.2.min.js file and IE version is 11 and portal version is 7.4. Screenshot for the IE error is attached as well.

    Please let me know if I am missing anything here?

  • Hi,

    First of all, thank you for the article.

    I followed the instruction, created the portal application package and deployed successfully to the server. I can see the page in the “content administration” -> “portal content management” -> “Portal applications”. Note: I can’t see it in “Web Dynpro Java Applications”.

    I copied the “TimeOut” dyn page and “pasted as PCD object” to the folder that i store iviews in “Portal Content” folder. Note: The iview created from template as “Web Dynpro application” gave me “resource does not exist” error.

    I added the iview to the customized Ajax framework page as “container for Technical Hidden iviews”.

    I changed the master rule to adopt the custom desktop which with custom ajax framework page.

    Logoff, clean browser cache, logged back in. Nothing happened after 2 min.

    I checked the browser F12. I can see the TimeOut div in the source. with error: "Object doesn't support property or method 'querySelector' "

    Could you please help? Appreciated

  • Hi All,

    I am getting below "Portal run time error"  after idle session while calling.



    Thanks & Regards,



  • Hi Sharadha,

    As per this blog, once the popup is displayed and the user does not click on OK and cancel, user continues to be on the same page.Additionally , if the user clicks  the mouse but does not click on OK or Cancel button, the timer is reset even though the user has not performed any activity on webpage.Is there any way to override the popup and force logout in such situation .