0

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.
enter image description here

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
        ];
    }
}
11
  • Your Apex controller is called PollVotesController. It looks like your component may be declaring a dependency on a putative class called FeedPollVote, which is an sObject name.
    – David Reed
    Commented Dec 7, 2018 at 16:57
  • @DavidReed can you expand on your comment? I am just querying the object FeedPollVote. Is there something else I need to do to allow a non-SysAdmin to query it via apex? Commented Dec 7, 2018 at 17:00
  • I'm speculating, really - but the error you're receiving does not look like an Apex exception, it looks like the runtime getting confused by something. I was wondering whether any of your components declare a controller called FeedPollVote. Can you share your component markup?
    – David Reed
    Commented Dec 7, 2018 at 17:02
  • @DavidReed I modified my question to include code. Commented Dec 7, 2018 at 17:06
  • 1
    You're belief appears to be incorrect @MicheleKleinhomer The code <aura:attribute name="Users" type="FeedPollVote" /> clearly shows that it's not FeedPollVote[] 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.
    – gNerb
    Commented Dec 7, 2018 at 17:42

1 Answer 1

0

Does that non-admin profile have read access to the FeedPollVote object? I've never used the object before, but also if it has a parent that could also impact access if it controls sharing access to the child (FeedPollVote). Although if it still failed with "without sharing" then my guess would be object permission settings for that profile.

3
  • From what I can tell, FeedPollVote is a system object. I don't know of a way to assign rights to it. Do you? Commented Dec 13, 2018 at 16:53
  • This is way late, but did you ever resolve this issue? Looking at it again I'm also wondering if it could also be due to the Apex Controller class not being assigned to those User profiles. It could also be related to the user license for that profile and settings around Chatter / Feed Tracking / ConnectAPI access, for example. Sometimes those types of platform features will be restricted by license or even settings for a specific user.
    – Sam Howle
    Commented Apr 23, 2021 at 16:39
  • Sam - I have been using the component as an admin. I think I will revisit it to see if I can get it to work for non-admin. It was a couple of years ago when I worked on this & I feel like I know a lot more now than I did then. It became a low priority since I could retrieve the results myself. I will let you know how I make out. Commented Apr 23, 2021 at 21:25

You must log in to answer this question.

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