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 > 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.