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.
Component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName"
access="global"
controller="PollVotesController">
<aura:attribute name="FeedPollVotes" 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.FeedPollVotes}" var="feedpollvotes">
<tr scope="row">
<td> {!feedpollvotes.LastModifiedDate}</td>
<td> {!feedpollvotes.CreatedBy.Name}</td>
<td> {!feedpollvotes.CreatedBy.User_Organization_Name__c}</td>
<td> {!feedpollvotes.CreatedBy.User_Tier_Level__c}</td>
<td> {!feedpollvotes.Choice.ChoiceBody}</td>
</tr>
</aura:iteration>
</tbody>
</table>
</aura:set>
</lightning:card>
Client Controller
({
doInit: function(component, event, helper) {
var action = component.get("c.getFeedPollVotes");
action.setCallback(this, function(data) {
component.set("v.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
];
}
}
PollVotesController
. It looks like your component may be declaring a dependency on a putative class calledFeedPollVote
, which is an sObject name.FeedPollVote
. Can you share your component markup?<aura:attribute name="Users" type="FeedPollVote" />
clearly shows that it's notFeedPollVote[]
Should be<aura:attribute name="Users" type="FeedPollVote[]" />
As an aside, although I don't think it is, if it's an apex error there will be something in debug logs so turn on debug logs for your user and check there. Also make sure to hit f12 in browser to view console to see if there are any JS errors.