B2B Service

Get Involved. Join the Conversation.

Topic

    Hamzeh Al Karmi
    Preventing certain users from viewing field values
    Topic posted March 5, 2019 by Hamzeh Al KarmiSilver Medal: 2,000+ Points, last edited March 5, 2019 
    168 Views, 11 Comments
    Title:
    Preventing certain users from viewing field values
    Summary:
    Customize Service Request Status field so that certain users cannot view the value "Resolved"
    Content:

    Hello experts,

    Can I perform an action where certain users cannot view the value "Resolved" in the Service Request Status while others can? I thought of creating a custom field called Service Request Status and displaying the page that contains the custom field to certain roles but I was told it will affect the reports that display SRs based on certain statuses.

    Thank you,

    Comment

     

    • Chris Warner

      I haven't done this type of configuration myself but I have seen others use one of the two following options:

      1. Create two dynamic layouts and in one of the layouts remove the field; make this page only available to your restricted role(s) and make the other page available to all other roles.
      2. Edit the field on the Page and add a Groovy Expression for "Visible", enabling/disabling this based on the user's role.  (Sadly, I do not have sample Groovy for this.)

      As I understand it, option 1 is simpler to do (little/no code) but a little more complicated to manage; option 2 is vice versa, of course.

      • Hamzeh Al Karmi

        Hello Chris,

        I thought of the first option but as I understood it will affect the reports in the sense that if I want to generate SRs that are Open the system may get confused as there are two SR Status fields. Am I correct in this understanding?

        Regarding the second point I updated the script for the field in the Field Rules screen by entering the below script but as a result, the system generates an error for all statuses except the status Resolved. The script is:

         

        if (StatusCd=='RESOLVED')
                 {
                     if (adf.context.getSecurityContext().isUserInRole('ORA_SVC_CUSTOMER_SERVICE_REPRESENTATIVE_JOB')) {
                        // if has Employee role, then can not update Status field
                        return false
                     }
                   else
                   {
                     return true
                   }
               }

        I went to Objects > Standard Objects > Service Request > Fields > Standard > Select Status and tried entering a script on the Field Status but it generated a message "You need to select a lookup type for the choice list" and when pressing the Edit selected lookup type the pop up window is completely blank.

        • Chris Warner

          'I thought of the first option but as I understood it will affect the reports in the sense that if I want to generate SRs that are Open the system may get confused as there are two SR Status fields. Am I correct in this understanding?'

          No, there is still only a single field; you are only removing this field from one of the layouts, not from other layout or the underlying object.  It will not affect the reporting on this field.

          • Hamzeh Al Karmi

            If I create a custom field called Service Request Status and include all values except Resolved and add this field to the layout for the service representatives only and the predefined field that contain all values except Resolved with the second layout to be displayed for the manager. 

            This step will not affect the reporting? In BI I have to add a column called Status. Won't there be 2 status fields?

            • Chris Warner

              Ah, yes, if you create a second field you will certainly have two fields to deal with in your reporting.  I think in your particular case Option 2 is your best (perhaps only) real choice.  I will see if I can find a Groovy guru to help with this approach.

               

              • Hamzeh Al Karmi

                Thank you Chris that would be great I'd appreciate it.

                • Chris Warner

                  I talked with my Groovy gurus and they tell me they do not know of a way to hide values from a list (like an LOV).  As a fallback option, they suggested perhaps you can write a Groovy validation so that if a user with a specific role selects a value you can return a warning/error.  Not great but the best option I have heard.

                  • Hamzeh Al Karmi

                    Thank you Chris,

                    I tried using the script below:

                    def p_userName = adf.context.getSecurityContext().getUserName(); // this is how to get login user's user name
                    if(adf.context.getSecurityContext().isUserInRole('ORA_SVC_CUSTOMER_SERVICE_REPRESENTATIVE_JOB') ) 
                    {
                    isAttributeChanged('StatusCd') && StatusCd=='Resolved'
                    return false
                    }

                    But the user with the customer service representative job was able to change the value to resolved easily without any notifications.

                    I entered the script via the Detailed Page layout --> Clicking on the Status field in the section SolutionEdit Solution Subtab --> From the LOV in the field Updatable I selected Expression and entered the above script. Does your Groovy guru experts have a solution or a proper script I can use? Or is there a script I can use that hides a value from a field based on a user role?

                  • Hamzeh Al Karmi

                    Hello Chris,

                    The issue was resolved thankfully by adding the below script to the Triggers section in the Server Scripts screen:

                     

                    if (adf.context.getSecurityContext()?.isUserInRole('ORA_SVC_CUSTOMER_SERVICE_REPRESENTATIVE_JOB') && StatusCd=="ORA_SVC_RESOLVED")
                    {
                      throw new oracle.jbo.ValidationException('You are not allowed to set status to RESOLVED, please assign SR to Customer Service team.')
                    }

                     

                    • Reghu

                      Dear Hamzeh,

                       

                      Sorry I couldn't respond earlier. As I told  you over email that my Customer connect Account was not working, I was not able to view or edit any posts.

                      We have a ER for this already.   For now this is the workaround we also have used.

                       

                      Regards

                      Reghu

                      • Hamzeh Al Karmi

                        Dear Reghu,

                        Thank you for your reply. As the issue is now thankfully resolved I am trying to figure out how to hide the Response value from the Compose button for certain users. I want certain users to not be able to compose a response to the customer and I removed the Response value from the Actions menu but it still appears when I press compose.

                        Is there a workaround for this one? I entered the below script in the path: Standard Objects --> Service Requests --> Messages --> Server Scripts --> Validation Rules (Field Rules) but the system generated my error message for all users even though I added the ORA_SVC_CUSTOMER_SERVICE_REPRESENTATIVE_JOB role:

                        if (adf.context.getSecurityContext()?.isUserInRole('ORA_SVC_CUSTOMER_SERVICE_REPRESENTATIVE_JOB') && ChannelId=="ORA_SVC_RESPONSE")
                        {
                          throw new oracle.jbo.ValidationException('Sorry. You are not allowed to contact the customer. Please contact your Customer Service Team Members')
                        }