salesforce - Do calls to Schema.getGlobalDescribe() not run in system context in classes declared as without sharing? -


i have user profile disabled except api only , api enabled. user profile given access set of classes have rest services defined within them.

i seeing strange behavior when calling schema.getglobaldescribe(). receive different response depending on class call method from, if of classes defined same way. here's simplified version of problem:

global without sharing class webserviceclass {    {     system.debug(webserviceclass.fieldscontainname()); // returns true     system.debug(utilityclass.fieldscontainname()); //this returns false!   }    global static boolean fieldscontainname() {     system.debug(schema.getglobaldescribe().get('contact').getdescribe().fields.getmap().keyset().contains('name'));   } }  global without sharing class utilityclass {   global static boolean fieldscontainname() {     system.debug(schema.getglobaldescribe().get('contact').getdescribe().fields.getmap().keyset().contains('name'));   } } 

why be?

without sharing affects sharing (i.e. rows can see), has no affect on system mode vs user mode. typically triggers run in system mode, other apex entry points web services run in user mode.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -