1

The issue occurs when a bit more restricted profile is being used, so I am still reviewing whether it is actually the cause or if it's something else.

n.b. we are working in a namespaced scratch org, trying to describe field such as IsActive works fine.

Edit: Seems that only sysadmin can describe this field, code:

public with sharing class descriptor {
    @auraenabled public static void describer(){
        Schema.User.LastPasswordChangeDate.getDescribe();
    }
}

Edit 2: The root cause seems to be "Manage Users" permission on profile, which sort of makes sense but not really. I feel like it's a bug.

Edit 3: Managed to find a warkaround by catching and comparing sObjectException.getMessage(), although that opened a new can of worms as there are tons of code that never anticipated a null describe 🙃

2
  • Do you have the same issue from a without sharing class? Anything special about the apex context you're seeing this in? Jan 11 '18 at 11:55
  • @ca_peterson it's the "Manage Users" permission. I can't even to a comparison without throwing an exception: if (fToken != Schema.User.LastPasswordChangeDate){ ... }
    – dzh
    Jan 11 '18 at 23:46
-2

Schema.GetGlobalDescribe().Get(SObjectName).GetDescribe().Fields.GetMap().get('prefix__Field__c').getDescribe().getName() - works in all versions

3
  • Well the OP is getting an error message that it doesn't for their profile/package licenses/etc. How do you explain that?
    – Keith C
    Jan 11 '18 at 11:59
  • namespace enabled, the API v34.0 requires the namespace prefix for the describe calls. It's interesting the fact that adding the namespace prefix to the field worked in all versions (from 26 all the way to the current version), but trying to describe the field without the namespace prefix only worked until v33.0. Jan 11 '18 at 12:04
  • 1
    Ok. But its a User object field mentioned in the error message not a custom object that has a namespace...
    – Keith C
    Jan 11 '18 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.