Skip to main content
added 51 characters in body
Source Link
gNerb
  • 9.6k
  • 5
  • 27
  • 58
public without sharing class PollVotesController {
    @AuraEnabled
    public static List<FeedPollVote> getFeedPollVotes(){
        return  [SELECT[
            SELECT LastModifiedDate, CreatedBy.Name, CreatedBy.User_Organization_Name__c, 
                CreatedBy.User_Tier_Level__c, Choice.ChoiceBody 
             from FeedPollVote];FeedPollVote
        ];
    }
}

}

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];
}

}

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
        ];
    }
}
Updated variable names
Source Link

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];
    }
}

enter image description here
enter image description here

<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];
}

}

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];
    }
}

enter image description here

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName"
            access="global" 
            controller="PollVotesController">

<aura:attribute name="Users" 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.Users}" var="users">
                    <tr scope="row">
                        <td> {!users.LastModifiedDate}</td>
                        <td> {!users.CreatedBy.Name}</td>
                        <td> {!users.CreatedBy.User_Organization_Name__c}</td>                            
                        <td> {!users.CreatedBy.User_Tier_Level__c}</td>                                                        
                        <td> {!users.Choice.ChoiceBody}</td>                            
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
    </aura:set>
</lightning:card>
({
doInit: function(component, event, helper) {
    
    var action = component.get("c.getUsers");
    action.setCallback(this, function(data) {
        
        component.set("v.Users", data.getReturnValue());
        console.log(data.getReturnValue());
    });
    $A.enqueueAction(action);
}

})

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

<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>
({
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];
}

}

added 2268 characters in body
Source Link

Component

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName"
            access="global" 
            controller="PollVotesController">

<aura:attribute name="Users" 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.Users}" var="users">
                    <tr scope="row">
                        <td> {!users.LastModifiedDate}</td>
                        <td> {!users.CreatedBy.Name}</td>
                        <td> {!users.CreatedBy.User_Organization_Name__c}</td>                            
                        <td> {!users.CreatedBy.User_Tier_Level__c}</td>                                                        
                        <td> {!users.Choice.ChoiceBody}</td>                            
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
    </aura:set>
</lightning:card>

</aura:component>

Client Controller

({
doInit: function(component, event, helper) {
    
    var action = component.get("c.getUsers");
    action.setCallback(this, function(data) {
        
        component.set("v.Users", data.getReturnValue());
        console.log(data.getReturnValue());
    });
    $A.enqueueAction(action);
}

})

Component

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName"
            access="global" 
            controller="PollVotesController">

<aura:attribute name="Users" 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.Users}" var="users">
                    <tr scope="row">
                        <td> {!users.LastModifiedDate}</td>
                        <td> {!users.CreatedBy.Name}</td>
                        <td> {!users.CreatedBy.User_Organization_Name__c}</td>                            
                        <td> {!users.CreatedBy.User_Tier_Level__c}</td>                                                        
                        <td> {!users.Choice.ChoiceBody}</td>                            
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
    </aura:set>
</lightning:card>

</aura:component>

Client Controller

({
doInit: function(component, event, helper) {
    
    var action = component.get("c.getUsers");
    action.setCallback(this, function(data) {
        
        component.set("v.Users", data.getReturnValue());
        console.log(data.getReturnValue());
    });
    $A.enqueueAction(action);
}

})

added 34 characters in body
Source Link
Jayant Das
  • 30.7k
  • 3
  • 42
  • 68
Loading
Source Link
Loading