function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ksenia ChoateKsenia Choate 

Allow users read-only access to a subset of case fields on cases they do not own via a VF component

I need to be able to show a subset of case fields to users who don't own those cases. They have full CRED to cases and thus full rights to cases they own, but for the cases they don't own, they should be able to see a handful of fields (not all of them). OWD for cases is Private.

My original solution was to create a custom object that would mimic the case fields that should be public and make that object's OWDs Public Read-Only. The object would have a lookup field to the case (so that the data can be pulled from the case and into this object via the Process Builder) as well as to accounts and contacts (so that the records of this object would show up in related lists on accounts and contacts). I posted this solution on the success community to see if anyone had a more elegant solution and someone suggested that using Visualforce would be easier. (Link to the success community post: https://success.salesforce.com/answers?id=9063A000000pHkMQAU).

I know next to nothing about VF (not a developer), but happy to learn, at least enough to try to build this thing. I've been looking at this: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_display_field_values.htm and this: https://salesforce.stackexchange.com/questions/65623/expose-a-child-objects-vf-page-in-parent-objects-page-layout and it looks like I could create a custom VF component that would include the case fields in question and place it on account and contact page layouts as a related list of sorts.This component would basically have to pull select case fields and display them to all users, regardless of case OWDs.

I have the following questions in conjunction with all of this:

  1. Is what I described possible?
  2. If it is, are the two linked resources enough to help me figure it out, or is there anything else I should study?
  3. How does security work for VF components? Can I just add it to people's profiles to make the data displayed in them visible to all, even though case OWDs normally restrict them from seeing those fields?
  4. What happens when you have multiple case records, too many to fit into the component? Do you set the VF componenet's hight and then if the records don't fit within the specified height, a scroll bar appears?
  5. Will this VF page work in the context of a service cloud console (e.g., if someone is looking at an account or contact page in the console, will the VF component be rendered properly, or would a separate component have to be designed for the console)?


Thank you in advance!!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

Best Answer chosen by Ksenia Choate
Nithesh NNithesh N
From What I have understood, You want Others Users should be able to see the fields of the records which they Don't own But Shouldn't be able to Edit them. 

It is Possible in Visualforce. 

As you are new to Visualforce, This is the High level picture of it. 
Visualforce

I Recommend you to Use a Custom Controller with "without sharing" keyword, This way you can show the fields to the users which are not shared to them by default.
To know more about this in detail, Check https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm

Now, We need to Give Read only access to the User, We can do this by Setting Read Only Attribute to the Visualforce Page.
Example:
<apex:page controller="CustomContactController" readOnly="true">
    <p>Your Awesome Markup here.</p>
</apex:page>

Read more about it here https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_readonly_context_pagelevel.htm

If you want to show multiple case record details in The component, then its best to use List view like layout that shows table with the fields as columns you wanna to show.
Read about Custom List Controllers here. https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_custom_list_controller.htm
 

All Answers

Nithesh NNithesh N
From What I have understood, You want Others Users should be able to see the fields of the records which they Don't own But Shouldn't be able to Edit them. 

It is Possible in Visualforce. 

As you are new to Visualforce, This is the High level picture of it. 
Visualforce

I Recommend you to Use a Custom Controller with "without sharing" keyword, This way you can show the fields to the users which are not shared to them by default.
To know more about this in detail, Check https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm

Now, We need to Give Read only access to the User, We can do this by Setting Read Only Attribute to the Visualforce Page.
Example:
<apex:page controller="CustomContactController" readOnly="true">
    <p>Your Awesome Markup here.</p>
</apex:page>

Read more about it here https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_readonly_context_pagelevel.htm

If you want to show multiple case record details in The component, then its best to use List view like layout that shows table with the fields as columns you wanna to show.
Read about Custom List Controllers here. https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_custom_list_controller.htm
 
This was selected as the best answer
Ksenia ChoateKsenia Choate
Nithesh,

Thank you so much for your thoughtful, detailed, informative response! Now I don't want to do my regular admin work, I just want to learn how to do this :) Much appreciated!!