• TM_Mike
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

In an apex custom controller, is there a way to determine the current user's sharing access for a custom object record?

Example:

//Standard building of a custom select list
List<SelectOption> theList = new List<SelectOption>{};

List<CustomObject__c> items = Database.query(query);
                        for(CustomObject__c i : items){
                                theList.add(new SelectOption(i.id, i.name));
                        }

 



//What I would like to do
List<SelectOption> theList = new List<SelectOption>{};

List<CustomObject__c> items = Database.query(query);
                        for(CustomObject__c i : items){
                               
                               //determine user sharing rights on record
                               boolean optionDisabled = false;
                               string?? userAccess = i.methodThatReturnsCurrentSharingAccess;
                               if(userAccess != 'read/write'){
                                         optionDisabled = true;
                               }
                                theList.add(new SelectOption(i.id, i.name, optionDisabled));
                        }

 



I understand that I would probably need to get the current user object using the global and pass that to whatever method determines the sharing access. Unless the user object has the method and I pass it the record object. I will look into that while I wait for a reply.

 

 

Mike

In an apex custom controller, is there a way to determine the current user's sharing access for a custom object record?

Example:

//Standard building of a custom select list
List<SelectOption> theList = new List<SelectOption>{};

List<CustomObject__c> items = Database.query(query);
                        for(CustomObject__c i : items){
                                theList.add(new SelectOption(i.id, i.name));
                        }

 



//What I would like to do
List<SelectOption> theList = new List<SelectOption>{};

List<CustomObject__c> items = Database.query(query);
                        for(CustomObject__c i : items){
                               
                               //determine user sharing rights on record
                               boolean optionDisabled = false;
                               string?? userAccess = i.methodThatReturnsCurrentSharingAccess;
                               if(userAccess != 'read/write'){
                                         optionDisabled = true;
                               }
                                theList.add(new SelectOption(i.id, i.name, optionDisabled));
                        }

 



I understand that I would probably need to get the current user object using the global and pass that to whatever method determines the sharing access. Unless the user object has the method and I pass it the record object. I will look into that while I wait for a reply.

 

 

Mike