The Following Component is used in the Community and used through Partner Portal profile.

Lightning Component

<lightning:recordEditForm recordTypeId="xxxxxxxxx" objectApiName="Case" onsuccess="{!c.handleSuccess}">
    <lightning:inputField fieldName="CaseDescription__c"  />
    <lightning:inputField fieldName="Subject"  />
    <lightning:inputField fieldName="Severity__c"  />

    <lightning:button class="slds-m-top_small"
                      label="New Case">


Javascript Controller

     handleSuccess : function(component, event, helper) {
        var payload = event.getParams().response;
         console.log('Record id : '+payload.id);

There is a trigger on the Case object which runs on creation of a Case record.

trigger CaseTriggerHandler on Case (after insert,after update) {

    List<User> usrList = [SELECT Name,TimeZoneSidKey FROM User];
    System.debug('usrList '+usrList);
    System.debug('usrListSize '+usrList.size());

[SELECT Name,TimeZoneSidKey FROM User];

The above query is returning only Users of Portal Users profile but not others. Since Trigger runs in system mode why is it not fethcing all the Users that exists in the System ? If i put a WHERE Condition to the query with some other profile id, the query returns NULL.

Note : If use Apex Controller instead of standard submit of lightning record edit and create a record, SOQL DOES return all the Users data correctly. It is NOT returning only when used stanadard submit of lightning record edit form. Since the query is placed in the Trigger why there should be any access issue since it runs in System Mode.

Why the Standard Submit is giving this problem ?

  • What's your use case why are you querying all users?
    – RedDevil
    May 10, 2019 at 18:05
  • Well the actual query gets only one particular user. Just to make things simple i put that way. The thing is data exists in DB but still returning null.
    – steamyfire
    May 11, 2019 at 2:12

3 Answers 3


My only guess would be related to inherited sharing. The standard submit likely calls some code on the backend that has sharing enabled and your trigger inherits these sharing rules.

To test this theory, try moving your query into a helper class. Add without sharing to that helper class and then call that method from the trigger:

Helper Class:

public class without sharing CaseService {
    public static void testSharing() {
        List<User> usrList = [SELECT Name,TimeZoneSidKey FROM User];
        System.debug('usrList '+usrList);
        System.debug('usrListSize '+usrList.size());


trigger CaseTriggerHandler on Case (after insert,after update) {

If you see results, then this is likely the issue, if not, there is something else going on.


In the community builder there is Administration section with Members option, there what all the profiles are added it is able to fetch only those profile'd users. I thought those profiles were only for logging into the community purpose. But standard LDS and other actions seems to depending on it. Once i added more profiles, the data was accessible accordingly.


Update the CaseTriggerHandler API version to 48. It will return non-community users also.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .