9 Replies Latest reply: Jun 25, 2012 6:50 PM by Kristy Van Der Vlist RSS

    showing screen based on user

      Hi Experts,

      I have a requirement where I need to show screen based on the user logged in.


      If the user is guest then SCREEN 1 will be displayed
      If user is not guest then SCREEN 2 is displayed.

      How can this functionality be achieved.
      Any pointers will be of great help.

        • 1. Re: showing screen based on user
          The Oracle Policy Automation Developers guide under Oracle Policy Automation Tools may provide more insight. Search for Interview topic and subtopics.
          • 2. Re: showing screen based on user
            Thanks for the reply.

            I can think of two approaches to do this

            1. use a boolean attribute to check if the user is "guest" and the directing to screens using screen flow.
            (but how to access this user attribute from url and then write rule ?)

            2. Based on the user pre-populate opa attribute if user is not equal to guest in the screen using vm templates and then if the attribute is known direct to different screen using screen flow.
            (but how to populate an OPA attribute value from VM template?)

            • 3. Re: showing screen based on user
              You are correct in that to do this need to get the username into the rules session somehow. So there are 2 problems:
              1. How to represent the user in the rules session
              2. How to manage the display of different screens

              Regarding 1, create a global attribute for the username. The "user=guest" that you see in the URL for OWD is not really used for anything internally. The SecurityService is non-functional in the OPA at the moment. The username (security token) is passed to the InterviewEngine at session creation time but is not used. So to access this piece of information you could possibly create an OnRequireSessionEventHandler which will provide you with the user information and then create your own session and populate the username into the new session. (Ideally you would use an OnSessionCreatedEventHandler but you do not have access to the SecurityToken in this callback). Another option is to implement an OnRequestEventHandler and access the web request directly to get the username and write it into the session.

              Regarding 2, if it is a question screen that needs to be displayed differently for the users then as you suggest a screen flow branching on the username could then be used, or if you are not using screen flows and instead using attribute goals then use procedural rules to manage navigation. If it is the summary screen that needs to vary then you can place all the controls for each user into folders and apply visibility attributes at the folder level to achieve the effect you desire. (depending on how complicated and different the 2 question screens are you could use visibility attributes on each control, i.e. put both logical screens into 1 OPA screen, just hiding the controls not relevant to the specific user)

              Hope that helps.
              • 4. Re: showing screen based on user
                To set user id into an attribute, you can use the below code in quesiton screen.vm

                $screen().getInterviewSession().getRuleSession().getGlobalEntityInstance().getEntity().getAttribute("user_vid").setValue($screen().getInterviewSession().getRuleSession().getGlobalEntityInstance(), "OPAUSER")

                You can access user using {user} in vm
                • 5. Re: showing screen based on user
                  Kristy Van Der Vlist
                  Unless your intent is to corrupt your session then I suggest you don't do it this way. If you want to set values in the session you must use the methods provided by the Interview API. The easiest implementation is likely to be the one that Brad suggested.
                  • 6. Re: showing screen based on user
                    Hi Kristy,
                    what's harm in setting the attribute this way? How deos the session gets corrupted?
                    • 7. Re: showing screen based on user
                      Kristy Van Der Vlist
                      See http://docs.oracle.com/html/E27555_01/Content/Get%20Started/Interview_Engine.htm.

                      You will lose data and the behaviour of the system from that point on will be undefined.. As a result, as of 10.3 onwards, doing this will cause the engine to throw an exception.
                      • 8. Re: showing screen based on user
                        Kristy, then I might have to set this attribute on some event handler like onrequesteventhander or onsubmit?
                        Am I correct or even that will corrupt the session?
                        • 9. Re: showing screen based on user
                          Kristy Van Der Vlist
                          No not if you do it properly. As I said, if you want to set values in the session you must do so using the methods provided by the Interview API see http://docs.oracle.com/html/E24274_01/Content/Technical%20Reference/Exrtensions_Undstnd_IntSess.htm