function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SaurabhDuaSaurabhDua 

Lightning Component Framework Specialist-- step 8

Help needed with the below error
User-added image

Here is my component

<aura:component>
     <aura:attribute name="boat" type="BoatType__c" access="public"/>
    <aura:handler name="change" value="{!v.boat}" action="{!c.refresh}"/>
    <!-- set up the aura:method for refresh -->
    <aura:method name="refresh" action="{!c.doInit}" access="public"
                 description="BoatDetailsController.js invokes refresh whenever boat is updated">
    </aura:method>
     
    <ui:scrollerWrapper class="scrollerSize">
        <!--Scrollable content here -->
        <aura:if isTrue="{!v.boatReviews.length==0}">
            <lightning:layoutItem class="slds-align_absolute-center" flexibility="auto" padding="around-small">   
                <ui:outputText value="No Reviews Available" />
            </lightning:layoutItem>
        </aura:if>
        <div class="slds-feed">
            <ul class="slds-feed__list">
                <aura:iteration items="{!v.boatReviews}" var="boatReview">
                    <li class="slds-feed__item">
                        <div class="slds-media__body">
                       <div class="slds-grid slds-has-flexi-truncate">
                            <a href="javascript:void(0)" onclick="{!c.onUserInfoClick}"
          data-userid="{!boatReview.CreatedBy.Id}">
          {!boatReview.CreatedBy.Name}
      </a>
                        &nbsp; &mdash; &nbsp; {!boatReview.CreatedBy.CompanyName}
   </div>
                         <p><lightning:formattedDateTime value="{!boatReview.CreatedDate}" 
                                   year="numeric" month="short" day="numeric"  
                                   hour="2-digit" minute="2-digit" hour12="true"/></p>
                        </div>
                    </li>
                </aura:iteration>
            </ul>
        </div>
    </ui:scrollerWrapper>
    
    
</aura:component>
Best Answer chosen by SaurabhDua
gauravbtgauravbt
Here is the answerc. Check the BOld 
In BoatReviews.cmp
Use
     <aura:attribute name="boat" type="Boat__c" access="public"/>
instead of

     <aura:attribute name="boat" type="BoatType__c" access="public"/>


Please mark it as SOLVED . It worked for me!

All Answers

gauravbtgauravbt
Any Luck @SaurabhDua ?
SaurabhDuaSaurabhDua
No, still the same ! Get Outlook for iOS
gauravbtgauravbt
Here is the answerc. Check the BOld 
In BoatReviews.cmp
Use
     <aura:attribute name="boat" type="Boat__c" access="public"/>
instead of

     <aura:attribute name="boat" type="BoatType__c" access="public"/>


Please mark it as SOLVED . It worked for me!
This was selected as the best answer
ani gho 10ani gho 10
2 things going on here the error "BoatReview component does not include a public attribute..... of type boatType__c and the the BoatReview not getting saved ..... with a compilation error its a catch 66 type you fix one the other comes up

follwing helped me
# 1 add an apex class BoatReviews.apex most important
public class BoatReviews {
          @AuraEnabled
          public static list<BoatReview__c> getAll(Id boatId) {
                  
          return [SELECT Id,Name,Comment__c,Rating__c,LastModifiedDate,CreatedDate,CreatedBy.Name,CreatedBy.SmallPhotoUrl,CreatedBy.CompanyName FROM BoatReview__c WHERE Boat__c=:boatId];
         }
          
          }
the dependency you might need to revisit just in case....
#2 fyi refrence how my BoatReviews.cmp loooks
<aura:component controller="BoatReviews">
           <aura:attribute name="boat" type="Boat__c"/>
           <aura:attribute name="boatReviews" type="BoatReview__c[]" access="private"/>
           <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
           <!-- set up the aura:method for refresh -->
              <aura:method name="refresh" action="{!c.doInit}" access="public"
                 description="BoatDetailsController.js invokes refresh whenever boat is updated">
    </aura:method>
          <aura:handler name="change" value="{!v.boat}" action="{!c.doInit}"/>
          
          <aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
          <ui:scrollerWrapper class="scrollerSize">
          <!--Scrollable content here -->
          <aura:if isTrue="{!v.boatReviews.length==0}">
          <lightning:layoutItem class="slds-align_absolute-center" flexibility="auto" padding="around-small">   
          <ui:outputText value="No Reviews Available"/>
          </lightning:layoutItem>
          </aura:if>
          <div class="slds-feed" style="max-height:          0px;">
          <ul class="slds-feed__list">
          <aura:iteration items="{!v.boatReviews}" var="boatReview">
          <li class="slds-feed__item">
          <header class="slds-post__header slds-media">
          <div class="slds-media__figure">
          <img alt="Image" src="{!boatReview.CreatedBy.SmallPhotoUrl}" title=""/>
          </div>
          <div class="slds-media__body">
          <div class="slds-grid slds-grid_align-spread slds-has-flexi-truncate">
          <p>
          <a href="javascript:void(0)" onclick="{!c.onUserInfoClick}" data-userid="{!boatReview.CreatedBy.Id}">
          {!boatReview.CreatedBy.Name}
          </a>-{!boatReview.CreatedBy.CompanyName}
          </p>
          </div>
          <p class="slds-text-body_small">
          <lightning:formattedDateTime value="{!boatReview.CreatedDate}" 
          year="numeric" month="short" day="numeric" hour="2-digit" minute="2-digit" hours="true"/>
          </p>
          </div>
          </header>
          <div class="slds-post__content slds-text-longform">
          <div>
          <ui:outputText value="{!boatReview.Name}"/>              
          </div>
          <div>
          <ui:outputRichText class="slds-text-longform" value="{!boatReview.Comment__c}"/>
          </div>
          </div>
          <footer class="slds-post__footer">
          <ul class="slds-post__footer-actions-list slds-list_horizontal">
          <li class="slds-col slds-item slds-m-right_medium">
          <c:FiveStarRating aura:id="FiveStarRating" value="{!boatReview.Rating__c}" readonly="true"/>
          </li>
          </ul>
          </footer>
          </li>
          </aura:iteration>
          </ul>
          </div>
          </ui:scrollerWrapper>
          </aura:component>
BoatReviewsController.js
({
           doInit: function(component, event, helper) {
           helper.onInit(component, event);
           },
           onUserInfoClick: function(component,event,helper){
           var userId = event.currentTarget.getAttribute("data-userid");
           var navEvt = $A.get("e.force:navigateToSObject");
           navEvt.setParams({
           "recordId": userId,
          });
          navEvt.fire()
          
         }
          })

BoatDetails.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
           <aura:attribute name="selectedTabId" type="String"/>
           <aura:attribute name="boat" type="Boat__c"/>
           <aura:attribute name="id" type="Id"/>
           <aura:attribute name="recordError" type="String"/>
           <aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
           <aura:handler event="c:BoatSelected" action="{!c.onBoatSelected}"/>
           <aura:handler name="boatReviewAdded" event="c:BoatReviewAdded" action="{!c.onBoatReviewAdded}"/>
           <force:recordData aura:id="service"
                   layoutType="FULL"
                   recordId="{!v.id}"
                   fields="Id,Name,Description__c,Price__c,Length__c,Contact__r.Name,
                   Contact__r.Email,Contact__r.HomePhone,BoatType__r.Name,Picture__c"
                   targetError="{!v.recordError}"
                   targetFields="{!v.boat}"
                   mode="EDIT"
                   recordUpdated="{!c.onRecordUpdated}"
                  />
                       
                   <lightning:tabset variant="scoped" selectedTabId="{!v.selectedTabId}" aura:id="details">
                   <lightning:tab label="Details" id="details">
                   <aura:if isTrue="{!not(empty(v.id))}">
                   <c:BoatDetail boat="{!v.boat}"/> 
                   </aura:if>
                   </lightning:tab>
                   <lightning:tab label="Reviews" id="boatreviewtab">
                              
                   <aura:if isTrue="{!not(empty(v.id))}">
                   <c:BoatReviews boat="{!v.boat}" aura:id="BRcmp"/> 
                   </aura:if>
                   </lightning:tab>
                   <lightning:tab label="Add Review" id="addReview">
                   <aura:if isTrue="{!not(empty(v.id))}">
                   <c:AddBoatReview boat="{!v.boat}"/> 
                   </aura:if>
                   </lightning:tab>
                   </lightning:tabset>
                       
                   <aura:if isTrue="{!not(empty(v.recordError))}">
                   <div class="recordError">
                   <ui:message title="Error" severity="error" closable="true">
                   {!v.recordError}
                   </ui:message>
                   </div>
                   </aura:if>
                   </aura:component>
and BoatDetailsController.js
({
           init: function(component, event, helper) {
           component.set("v.enableFullDetails", $A.get("e.force:navigateToSObject"));
           },
           onBoatSelected: function(component, event, helper) {
           var boatSelected=event.getParam("boat");
           component.set("v.id",boatSelected.Id);
           component.find("service").reloadRecord();
                   
          },
          onRecordUpdated: function(component, event, helper){
                  
          },
          onBoatReviewAdded: function(component, event, helper) {
          console.log("Event received");
          component.find("details").set("v.selectedTabId",'boatreviewtab');
          var BRcmp = component.find("BRcmp");
          console.log(BRcmp);
          var auraMethodResult = BRcmp.refresh();            
         }
          
          })