• k78
  • NEWBIE
  • 10 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I'm curious if anyone has a good explanation why the exception below is thrown in the first case but not the second case.
Exception Thrown (and rightly so):
sobject so = [SELECT Id FROM Contact LIMIT 1];
System.debug(so.get('Name'));
...but not here:
sobject so = [SELECT Id FROM Contact LIMIT 1];
so.put('Description', 'This is a description');
System.debug(so.get('Name'));

In both cases I would hope that so.get('Name') would throw the exception but I have found this not to be the case.

Exception:
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contact.Name
  • August 27, 2015
  • Like
  • 0

If I am in salesforce I can go to a record, click on its sharing button and from there I can click on Expand List.  Next, I can find a username and click on the Why? link beside their name.  This will take me to the entitywhylist.jsp page which seems to simply be able to accept 2 arguments (record Id and user Id) and return a full explanation of what relationships and reasons permit the user to access that record.

 

My question then: Is there an Apex method that can do this.  If I have the record Id and the user Id is there an inexpensive way of returning the information provided by the entitywhylist page?  All the other similar solutions to questions like this seem to involve iterating over a potentially large number of groups and roles.

  • December 09, 2013
  • Like
  • 0
I'm curious if anyone has a good explanation why the exception below is thrown in the first case but not the second case.
Exception Thrown (and rightly so):
sobject so = [SELECT Id FROM Contact LIMIT 1];
System.debug(so.get('Name'));
...but not here:
sobject so = [SELECT Id FROM Contact LIMIT 1];
so.put('Description', 'This is a description');
System.debug(so.get('Name'));

In both cases I would hope that so.get('Name') would throw the exception but I have found this not to be the case.

Exception:
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contact.Name
  • August 27, 2015
  • Like
  • 0

If I am in salesforce I can go to a record, click on its sharing button and from there I can click on Expand List.  Next, I can find a username and click on the Why? link beside their name.  This will take me to the entitywhylist.jsp page which seems to simply be able to accept 2 arguments (record Id and user Id) and return a full explanation of what relationships and reasons permit the user to access that record.

 

My question then: Is there an Apex method that can do this.  If I have the record Id and the user Id is there an inexpensive way of returning the information provided by the entitywhylist page?  All the other similar solutions to questions like this seem to involve iterating over a potentially large number of groups and roles.

  • December 09, 2013
  • Like
  • 0