Search code examples
salesforceapex-codesoql

Calling .getDescribe() on result of SOQL query


If I have an SOQL query as follows, which returns only 1 field.

String this_soql = 'SELECT SUM(Revenue_Target__c) revenueTarget FROM DM_Account_Plan__c WHERE Id=: the_Id GROUP BY Id';

SObject r = Database.query(this_soql);

Can I then go on to get the 'getDescribe' of that field somehow? Somthing like this perhaps? (which doesnt work)

System.debug(r.getDescribe().isAccessible());

Any advice or suggestions would be greatly appreciated!


Solution

  • Found an answer.

    You can call the describe method via the SObject's SObjectType like this:

    System.debug(r.getSObjectType().getDescribe().isAccessible());