0

I have an existing Lightning Component, which is used in a lightning community. This component was version 39 on Friday. The following is a pared down example of the code (I just removed a bunch of fields and labels to make this post easier to read).

<aura:component controller="CommunityHoldingDetailController" >

    <aura:attribute name="holding" type="Holding__c" required="true" />
    <aura:attribute name="properties" type="CommunityServices.Property[]" />
    <aura:attribute name="showDetail" type="boolean" default="true" />
    <aura:handler name="init" value="this" action="{!c.getProperties}" />

    <div class="slds-tile slds-tile--board">
        <div onclick="{!c.toggleTx}" data-id="{!v.InvestmentRecord.investment.id}" class="{!v.holding.FMZ_Status__c == 'Active' ? 'slds-page-header slds-m-bottom--xx-small clicky headerBanner' : 'slds-page-header slds-m-bottom--xx-small clicky inactiveHeaderBanner'}" style="padding-bottom: 10px;padding-top:10px;" role="banner">
            <p class="slds-text-heading--label subheading">{!v.holding.FMZ_Status__c}&nbsp;{!$Label.c.Community_Investment_Detail}</p>
            <h1 class="slds-text-heading--medium slds-m-top--xx-small slds-m-bottom--xx-small">
                <span aura:id="plusSign" class="plusAndMinus hideMe">+</span>
                <span aura:id="minusSign" class="plusAndMinus">-</span>
                {!v.holding.Holding_to_Fund__r.Name}
            </h1>
        </div>
    </div>

    <div aura:id="details" id="{!v.holding.Id+'_details'}" class="slds-grid slds-wrap slds-page-header__detail-row slds-m-top--xx-small slds-m-bottom--xx-small slds-p-bottom--xx-small">
        <div class="slds-col--padded slds-size--1-of-1 slds-small-size--1-of-1 slds-medium-size--1-of-1">
            <div class="slds-grid slds-wrap slds-page-header__detail-row slds-m-top--xx-small">
                <div class="slds-col--padded slds-size--1-of-1 slds-small-size--1-of-1 slds-medium-size--1-of-1">
                    <h1 class="slds-text-heading--medium slds-m-top--xx-small slds-m-bottom--xx-small" style="font-size: 1.25rem;">
                        Community Investment Detail
                    </h1>
                </div>
                <div class="slds-col--padded slds-size--1-of-1 slds-small-size--1-of-2 slds-medium-size--1-of-2">
                    <div style="white-space: nowrap;">
                        <p class="slds-text-heading--label slds-truncate" style="display: inline-block;">
                            {!$Label.c.Community_Amount_Invested}
                        </p> 
                    </div>
                    <p class="slds-text-body--regular slds-m-bottom--small">
                        <ui:outputCurrency value="{!v.holding.Equity_Invested__c}" />
                    </p>
                </div>
            </div>
        </div>
    </div>
</aura:component>

I got a new request to add HelpText to some fields on this component. With a quick search through the docs I found that I could easily do that by using the <lightning:helptext> component that was released with version 41. I updated that components version, added the new help text components and everyone was happy. The following is a pared down version of what the component looked like at the end of the day on Friday. At version 41.

<aura:component controller="CommunityHoldingDetailController" >

<aura:attribute name="holding" type="Holding__c" required="true" />
<aura:attribute name="properties" type="CommunityServices.Property[]" />
<aura:attribute name="showDetail" type="boolean" default="true" />
<aura:handler name="init" value="this" action="{!c.getProperties}" />

<div class="slds-tile slds-tile--board">
    <div onclick="{!c.toggleTx}" data-id="{!v.InvestmentRecord.investment.id}" class="{!v.holding.FMZ_Status__c == 'Active' ? 'slds-page-header slds-m-bottom--xx-small clicky headerBanner' : 'slds-page-header slds-m-bottom--xx-small clicky inactiveHeaderBanner'}" style="padding-bottom: 10px;padding-top:10px;" role="banner">
        <p class="slds-text-heading--label subheading">{!v.holding.FMZ_Status__c}&nbsp;{!$Label.c.Community_Investment_Detail}</p>
        <h1 class="slds-text-heading--medium slds-m-top--xx-small slds-m-bottom--xx-small">
            <span aura:id="plusSign" class="plusAndMinus hideMe">+</span>
            <span aura:id="minusSign" class="plusAndMinus">-</span>
            {!v.holding.Holding_to_Fund__r.Name}
        </h1>
    </div>
</div>

<div aura:id="details" id="{!v.holding.Id+'_details'}" class="slds-grid slds-wrap slds-page-header__detail-row slds-m-top--xx-small slds-m-bottom--xx-small slds-p-bottom--xx-small">
    <div class="slds-col--padded slds-size--1-of-1 slds-small-size--1-of-1 slds-medium-size--1-of-1">
        <div class="slds-grid slds-wrap slds-page-header__detail-row slds-m-top--xx-small">
            <div class="slds-col--padded slds-size--1-of-1 slds-small-size--1-of-1 slds-medium-size--1-of-1">
                <h1 class="slds-text-heading--medium slds-m-top--xx-small slds-m-bottom--xx-small" style="font-size: 1.25rem;">
                    Community Investment Detail
                </h1>
            </div>
            <div class="slds-col--padded slds-size--1-of-1 slds-small-size--1-of-2 slds-medium-size--1-of-2">
                <div style="white-space: nowrap;">
                    <p class="slds-text-heading--label slds-truncate" style="display: inline-block;">
                        {!$Label.c.Community_Amount_Invested}
                    </p> 
                    <lightning:helptext content="This is a help text tooltip!" class="helpText"/>
                </div>
                <p class="slds-text-body--regular slds-m-bottom--small">
                    <ui:outputCurrency value="{!v.holding.Equity_Invested__c}" />
                </p>
            </div>
        </div>
    </div>
</div>

The sandbox where the changes were made got updated to the prerelease Spring '18 version Friday night.

Yesterday I went to make additional changes and found that the component could't compile. Just adding whitespace and saving it virtually the same as it was last Friday, would give me the following error.

enter image description here

After fiddling with it for a while, I discovered that the code would compile if I commented out the helptext component and lowered the version back down to 39 (actually even 40). But it will not compile at version 41 (or the new version, 42) while I have the type of the attribute "properties" set to an inner class. The same error is given when I try to save it with the type set as just a single inner class and not an array. I do not get the compile error when I use the type "Object", and I do not get the error when I use a non-inner class.

Here is the pared down version of the pertanet class.

public without sharing class CommunityServices {

    public class Property implements Comparable{
        @AuraEnabled
        public Property__c property{get;set;}
        @AuraEnabled
        public list<Image> images{get;set;}
        public Property(Property__c p){
            this.property = p;
            this.images = new list<Image>();
        }
        public void addImage(Attachment a){
            this.images.add(new Image(a));
        }
        // Implement the compareTo() method
        public Integer compareTo(Object compareTo) {
            Property compareToProp = (Property)compareTo;
            if (property.name == compareToProp.property.name) return 0;
            if (property.name > compareToProp.property.name) return 1;
            return -1;        
        }
    }
}

I see nothing in the release notes that indicates that inner classes can not be used in lightning attributes anymore. Also, one of the most frustrating things, is that this issue is affecting version 41, a version that was released to prod a few months ago.

Thanks!

0

1 Answer 1

1

I have components with nested classes as attributes working in v41. Are you sure that the class you're using is properly spelled and visible? What did come in is validation on save, which didn't happen at all in v40 or below.

See release notes: https://releasenotes.docs.salesforce.com/en-us/winter18/release-notes/rn_lc_validation_on_save.htm

Validations are applied only to components set to API version 41.0 and later. If the validation service prevents you from saving important changes, set the component version to API 40.0 or earlier to disable validations temporarily. When you’ve corrected the coding errors, return your component to API 41.0 or later to save it with passing validations.

Maybe it was a mistake in your code all along, because it makes no difference to the function of the component?

3
  • Thanks for the response. I'll buy it, but I can't find my mistake. I've added the inner class to my original post.
    – Dan
    Commented Jan 9, 2018 at 18:00
  • Now I can't help but wonder if it has to do with the comparable interface? But unfortunately I can't quickly change it to test. That class is referenced in many places throughout the org.
    – Dan
    Commented Jan 9, 2018 at 18:07
  • Looking at the other question, salesforce.stackexchange.com/questions/203955/…, I must be wrong. The org I tried this on doesn't have Spring 18 yet and I'd say this is a bug. If you save as v41 not v42, then the fact the org is Spring 18 shouldn't break this. Nonetheless, looks like you'll have to use Object[] for now in Spring 18 orgs.
    – Aidan
    Commented Jan 10, 2018 at 8:10

Not the answer you're looking for? Browse other questions tagged .