I have a Lightning component that works correctly when logged in as a SysAdmin. However, when logged in as a user with a different profile, the error below is received. I have without sharing
set in the controller. I thought the without sharing option would eliminate permission problems.
public without sharing class PollVotesController {
@AuraEnabled
public static List<FeedPollVote> getUsers(){
return [SELECT LastModifiedDate, CreatedBy.Name, CreatedBy.User_Organization_Name__c, CreatedBy.User_Tier_Level__c, Choice.ChoiceBody
from FeedPollVote];
}
}
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName"
access="global"
controller="PollVotesController">
<aura:attribute name="Users"name="FeedPollVotes" type="FeedPollVote"type="FeedPollVote[]" />
<aura:attribute name="PollID" type="String" />
<aura:attribute name="PollTitle" type="String" default="Poll" />
<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
<lightning:card title="{!v.PollTitle + ' Poll Results'}">
<aura:set attribute="body">
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<thead>
<tr class="slds-text-title_caps">
<th scope="col">Date</th>
<th scope="col">Name</th>
<th scope="col">Organization</th>
<th scope="col">Tier</th>
<th scope="col">Choice</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.UsersFeedPollVotes}" var="users">var="feedpollvotes">
<tr scope="row">
<td> {!usersfeedpollvotes.LastModifiedDate}</td>
<td> {!usersfeedpollvotes.CreatedBy.Name}</td>
<td> {!usersfeedpollvotes.CreatedBy.User_Organization_Name__c}</td>
<td> {!usersfeedpollvotes.CreatedBy.User_Tier_Level__c}</td>
<td> {!usersfeedpollvotes.Choice.ChoiceBody}</td>
</tr>
</aura:iteration>
</tbody>
</table>
</aura:set>
</lightning:card>
({
doInit: function(component, event, helper) {
var action = component.get("c.getUsers"getFeedPollVotes");
action.setCallback(this, function(data) {
component.set("v.Users"FeedPollVotes", data.getReturnValue());
console.log(data.getReturnValue());
});
$A.enqueueAction(action);
}
})
Server Controller
public without sharing class PollVotesController {
@AuraEnabled
public static List<FeedPollVote> getFeedPollVotes(){
return [SELECT LastModifiedDate, CreatedBy.Name, CreatedBy.User_Organization_Name__c, CreatedBy.User_Tier_Level__c, Choice.ChoiceBody
from FeedPollVote];
}
}