0

For my first real attempt at a lightning component, I am trying to make a related list that can be modified by different filters based on what you would like to see. I have it mostly working as intented, but I cannot seem to correctly query for related records, and am stuck either getting all of the records that meet my filter, or none.

I am attempting to use force:hasRecordId, which seems like it would make things quite simple, but I cannot seem to get it to work correctly even with the lightning component itself, as I try to display the recordId and get a blank component.

Code is below, any help is appreciated.

Component `

<lightning:card iconName="custom:custom84" title="Open Backlog Items" class="slds-is-relative">
    <div class="slds-p-left_medium slds-p-right_medium">
        <ul class="slds-list_vertical slds-has-dividers_top-space">
            <aura:if isTrue="{!v.openBacklogItems.length &gt; 0}">
                <aura:iteration items="{!v.openBacklogItems}" var="item">
                    <li class="slds-list__item">
                      <a href="{!'/lightning/r/BackLogItem__c/'+ item.Id + '/view'}" target="_blank">{! item.Name }</a>
                        <br></br>
                      Status :
                       {!item.Status__c}
                        <br></br>
                      <ui:outputRichText aura:id = 'desc' value = '{!item.Description__c}'/>
                    </li>
                </aura:iteration>
                <aura:set attribute="else">
                    <li class="slds-list__item">
                        <h3 class="slds-text-medium">{!recordID}</h3>

                    </li>
                </aura:set>
            </aura:if>
        </ul>
    </div>
</lightning:card>

`

JS Controller

({
    getOpenBacklogItems : function(component, event, helper) {
        var action = component.get("c.getRelatedBacklogItems");
        action.setParams({
            recordID : component.get("v.recordID")
        })
        action.setCallback(this, function(response){
            var relatedIssues = response.getReturnValue();
            component.set("v.openBacklogItems", relatedIssues);
        });
    $A.enqueueAction(action);
    }
})

Apex Controller

public with sharing class RelatedBacklogItemsController {

   @AuraEnabled
    public static List<BacklogItem__c> getRelatedBacklogItems(ID recordID){
        //TODO: Figure out how to filter by application record page being viewed
        return [SELECT Id, Name, Description__c, Level_of_Effort__c, Piority__c, Status__c FROM BacklogItem__c WHERE Status__c != 'Completed' AND Status__c != 'Rejected' AND Application__c = :recordID ORDER BY Status__c];
    }
}

I would think that this should query by application based on the record page we are looking at, but the query always returns nothing, and when I attempt to display recordId on the component using {!recordId} I am left with a blank component. I am guessing I am missing something quite simple, but have not been able to figure it out to this point.

1

Case Sensitivity: recordId and not recordID.

Pay attention to the value provider: {!v.XXX}

<li class="slds-list__item">
     <h3 class="slds-text-medium">{!v.recordId}</h3>
</li>

Also,

component.get("v.recordId")
  • I knew it would be something small I was overlooking like that, thank you for the second set of eyes. Saved me a lot of time pounding my head against the wall for an easy fix. – Frank Evers Aug 6 '18 at 14:29
  • Happy to help :-) – Lightning Evangelist Aug 6 '18 at 14:30

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.