3

I have been developing a basic lightning component to return all the names of my custom object "competitor" but am being thrown this error?

Assertion Failed!: Unable to get value for key 'competitor__c.Name'. No value provider was found for 'competitor__c'. : false Failing descriptor: {aura$iteration$controller$itemsChange}

Personally I cant see anything wrong with my approach so if someone else could give me some advice I would really appreciate it.

Thanks

CompetitorListController.apxc

public with sharing class CompetitorListController {

@AuraEnabled
public static List<Competitor__c> findAll() {
    return [SELECT id, name FROM Competitor__c LIMIT 50];
    }

}

CompetitorListController.cmp

<aura:component controller="CompetitorListController">

<aura:attribute name="competitors__c" type="competitor__c[]"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:handler event="c:SearchKeyChange" action="{!c.searchKeyChange}"/>

<ul>
    <aura:iteration items="{!v.competitors__c}" var="competitor">
        <li>
            <a href="{! '#/sObject/' + competitor__c.Id + '/view'}">
                <p>COMPETITORS GO HERE</p>
                <p>{!competitor__c.Name}</p>
            </a>
        </li>
    </aura:iteration>
</ul>

</aura:component>

CompetitorListController.js

({
doInit : function(component, event) {
    var action = component.get("c.findAll");
    action.setCallback(this, function(a) {
        component.set("v.competitors__c", a.getReturnValue());
    });
    $A.enqueueAction(action);
},


searchKeyChange: function(component, event) {
var searchKey = event.getParam("searchKey");
var action = component.get("c.findComp");
action.setParams({
  "searchKey": searchKey
});
action.setCallback(this, function(a) {
    component.set("v.competitors__c", a.getReturnValue());
});
$A.enqueueAction(action);
}

})
  • 1
    What if you remove the __c from the name of the attribute and spots where it is used as the view (v)? – Eric Nov 4 '16 at 16:09
  • Access Check Failed! AttributeSet.set(): 'competitors' of component 'markup://c:CompetitorList {7:0}' is not visible to 'markup://c:CompetitorList {7:0}'. – Nebbyyy Nov 4 '16 at 16:18
  • Great (sorta of) seems that solved your initial issue and now you have a different issue – Eric Nov 4 '16 at 16:20
  • @Nebbyyy Did you change competitors__c to competitors in all the places both in component and controller as Eric suggested. Also updated the question with new changes – Praveen Nov 4 '16 at 17:37
  • 2
    Be aware also that Lightning is case sensitive, even for object and field names. This tripped me up in the first few minutes of Lightning more than once; Apex Code has us spoiled. – sfdcfox Nov 4 '16 at 18:30
2

As discussed in comments, you should be using competitor instead of competitor__c from var="competitor".

Another situation in which this same error comes, when you forget to put the "v" i.e value provider to the key.

Uncaught afterRender threw an error in 'markup://ui:inputDateTime' [Assertion Failed!: Unable to get value for key 'progRecord.Start_Date__c'. No value provider was found for 'progRecord'. : false]

In my case, it key should be {!v.progRecord.Start_Date__c}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.