1

I'm having an issue with a handler which initially fires as expected for three times, but then stops responding after that.

The parent component has three attributes:

  1. A list of Custom SObjects
  2. A second list of the same type of SObjects
  3. A single SObject (which will be picked from one of the records in the 1st 2 attributes

The parent Component passes the first 2 attributes into 2 instances of the same component, which produces a table for each list.

The user can pick one of the records in the table (clicks a button) and this chosen record is shown in more detail beneath the tables.

I'm finding that after the third time a record is chosen, the additional detail isn't being updated.

When the record is chosen in the table components, I'm NOT firing an event to inform the parent component. Instead, the fact that the attributes are shared by reference between the components means that they are all linked together. Is there any reason why this would only work for a limited number of times? It's worth noting

Parent Component

<aura:component controller="CRS_OutcomeManagement_Controller" implements="flexipage:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName" >

<aura:attribute name="EAOutcomes" access="public" type="Service_Usage_Outcome__c[]"/>
<aura:attribute name="OtherOutcomes" access="public" type="Service_Usage_Outcome__c[]"/>
<aura:attribute name="chosenOutcome" access="public" type="Service_Usage_Outcome__c"/>

<aura:handler name="init" value="{!this}" action="{!c.populateTables}" />
<aura:handler name="change" value="{!v.chosenOutcome}" action="{!c.justCheck}"/>

<!-- THESE COMPONENTS SHOW THE TABLES OF SOBJECTS -->
<c:CRS_Outcomes_Table Outcomes="{!v.EAOutcomes}" outcomeType="EA" TableCaption="Early Adopter Outcomes" chosenOutcome="{!v.chosenOutcome}"/>
<c:CRS_Outcomes_Table Outcomes="{!v.OtherOutcomes}" outcomeType="Other" TableCaption="Outcomes from other Service Usages" chosenOutcome="{!v.chosenOutcome}"/>


<div class="{!(and(empty(v.EAOutcomes), empty(v.OtherOutcomes))) ? 'slds-align-absolute-center slds-m-top-x-large' : 'slds-hide'}">
    <p>This Person has had no Outcomes recorded yet. If they have open Service Usage records of the appropriate type, please use the "New Outcome" button.</p>
</div>

<aura:if isTrue="{!v.chosenOutcome.Id != null}">
    <!-- THIS COMPONENT KEEPS REFRESHING EVERY TIME THAT THE ATTRIBUTE CHOSENOUTCOME IS UPDATED -->
    <c:CRS_Outcome_SecondaryFields outcome="{!v.chosenOutcome}"/>

    <!--THIS COMPONENT STOPS REFRESHING AFTER THE THIRD TIME THE ATTRIBUTE CHOSENOUTCOME IS UPDATED-->
    <aura:if isTrue="{!v.chosenOutcome.RecordType.Name == 'EARLYADOPTER'}">
        <c:CRS_Outcome_Actions outcomeId="{!v.chosenOutcome.Id}" CRSProfile="{!v.recordId}" />
    </aura:if>
</aura:if>

Table components

<aura:component controller="CRS_OutcomeManagement_Controller" >
<aura:attribute name="Outcomes" type="Service_Usage_Outcome__c[]" default="[{'sobjectType': 'Service_Usage_Outcome__c'}]"/>
<aura:attribute name="outcomeType" type="string" required="true" description="Tells the table which columns to include"/>
<aura:attribute name="TableCaption" type="string" description="Provides a title for the table"/>
<aura:attribute name="chosenOutcome" type="Service_Usage_Outcome__c" description="Provides the ID of the chosen Outcome, so the row can be highlighted."/>

<div class="{!(v.Outcomes.length > 0) ? '' : 'slds-hide' }">
    <h3 class="slds-section-title--divider">{!v.TableCaption}</h3>
    <ui:scrollerWrapper class="tableHeight">
        <table class="slds-table slds-table--bordered slds-table--col-bordered slds-max-medium-table--stacked">
            <thead>
                <tr class="slds-text-heading--label">
                    <th scope="col"><span class="slds-truncate">Outcome</span></th>
                    <th scope="col"><span class="slds-truncate">{!(v.outcomeType == 'EA' ) ? 'Priority' : 'Related To:'}</span></th>
                    <th scope="col"><span class="slds-truncate">Date Identified</span></th>
                    <th scope="col"><span class="slds-truncate">Category</span></th>
                    <th scope="col"><span class="slds-truncate">View</span></th>
                </tr>
            </thead>
            <tbody>
                <aura:iteration items="{!v.Outcomes}" var="o">
                    <tr class="{!(o.Id == v.chosenOutcome.Id) ? 'slds-is-selected' : ''}">
                        <td>
                            <span class="slds-truncate">{!o.Person_Identified_Outcome__c}</span>
                        </td>
                        <td>{!(v.outcomeType == 'EA') ? o.Priority__c : o.Service_Usage__r.Service_Field__r.Name}</td>
                        <td>
                            <ui:outputDate value="{!o.Date_Identified__c}"/>

                        </td>
                        <td>{!o.Outcome_Category__c}</td>
                        <td>
                            <!-- THIS BUTTON SETS THE "CHOSENOUTCOME" ATTRIBUTE ON THIS COMPONENT AND, BY REFERENCE, THE PARENT COMPONENT-->
                            <button type="button" onclick="{!c.selectOutcome}" id="{!o.Id}">View</button>
                        </td>
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
    </ui:scrollerWrapper>
</div>

The component that stops refreshing contains a table of child records related to the chosen record.

<aura:component controller="CRS_OutcomeManagement_Controller" implements="flexipage:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName">

<aura:attribute name="outcomeId" access="public" type="string" description="This attribute allows the component to display the related actions"/>
<aura:attribute name="CRSProfile" access="public" type="string" description="The actions to display"/>

<aura:attribute name="newActionMode" type="boolean" access="private" default="false"/>
<aura:attribute name="relatedActions" access="private" type="Object[]" description="The actions related to this Outcome"/>
<aura:attribute name="otherActions" access="private" type="Object[]" description="The actions not-related to this Outcome, but could be related if chosen."/>

<aura:handler name="init" value="{!this}" action="{!c.populateTables}" />

<!-- THIS HANDLER STOPS RESPONDING AFTER THE THIRD TIME THE VALUE IS CHANGED-->
<aura:handler name="change" value="{!v.outcomeId}" action="{!c.populateTables}"/>

Actions Chosen Outcome Id - {!v.outcomeId}
<aura:if isTrue="{!v.outcomeId != null}">
    <div class="slds-box">

        <div class="slds-align--absolute-center slds-m-bottom--small">
            <ui:button label="{!(v.newActionMode == false) ? 'New Action' : 'Cancel'}" press="{!c.NewAction}"/>
        </div>

        <aura:if isTrue="{!v.newActionMode}">

            <c:CRS_Outcome_NewAction outcomeId="{!v.outcomeId}" CRSProfileId="{!v.CRSProfile}" />

            <aura:set attribute="else">
                <c:CRS_Outcome_ActionsTable tableActions="{!v.relatedActions}" tableTitle="Actions related to this Outcome" otherActions="{!v.otherActions}" outcome="{!v.outcomeId}" type="Related"/>
                <c:CRS_Outcome_ActionsTable tableActions="{!v.otherActions}" tableTitle="Other actions for this Person" otherActions="{!v.relatedActions}" outcome="{!v.outcomeId}" type="Other"/>
            </aura:set>
        </aura:if>
    </div>
</aura:if>

Your Answer

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

Browse other questions tagged or ask your own question.