• Priyank Anand
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Somehow I was not able to complete this challenge due to above error:
 
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId">

    <aura:attribute name="accountRecord" type="Account"/>
    <aura:attribute name="record" type="Object"/>
    <aura:attribute name="recordSaveError" type="String" default=""/>

    <force:recordData aura:id="recordHandler"
    recordId="{!v.recordId}"
    layoutType="FULL"
    targetRecord="{!v.record}"
    targetFields="{!v.accountRecord}"
    targetError="{!v.recordSaveError}"
    mode="EDIT"
    fields="Name"/>
    
    <!-- Display an editing form -->
    <div class="Record Details">
        <lightning:card iconName="action:edit" title="Edit Account">
            <div class="slds-p-horizontal--small">
                <lightning:input  label="Account Name" value="{!v.accountRecord.Name}"  name="Account Name"  />
                <br/>
                <lightning:button label="Save Account" onclick="{!c.handleSaveRecord}" class="slds-m-top--medium"/>
            </div>
        </lightning:card>
    </div>
        
    <!-- Display error message -->
    <aura:if isTrue="{!not(empty(v.recordSaveError))}">
        Error: <ui:outputText value="{!v.recordSaveError}"/>
    </aura:if>
 
 </aura:component>
 
({
    handleSaveRecord : function(component, event, helper) {
        component.find("recordHandler").saveRecord($A.getCallback(function(saveResult) {
            if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
                // handle component related logic in event handler
                component.set("v.recordSaveError", "");
                                
            } else if (saveResult.state === "INCOMPLETE") {
                console.log("User is offline, device doesn't support drafts.");
            } else if (saveResult.state === "ERROR") {
                console.log('Problem saving record, error: ' + JSON.stringify(saveResult.error));
                var errMsg = "";
                // saveResult.error is an array of errors, 
                // so collect all errors into one message
                for (var i = 0; i < saveResult.error.length; i++) {
                    errMsg += saveResult.error[i].message + "\n";
                }
                component.set("v.recordSaveError", errMsg);                
                
            } else {
                console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
            } 
        })); 
    }
})

Please help, Thanks :) 

Hi,
I created a lightning component that I embed in Community Builder custom page.
I called a apex controller function that will redirect to the Community Builder Home Page

This is my apex method
@AuraEnabled
    public static pageReference redirectToHomePage() {
        pageReference objHomePage = new PageReference('/');        
        return objHomePage;
    }

I'm not sure exactly how to call the Community Builder Home Page
I also get an error 'Return type does not support AuraEnabled'

I just want to redirect to Community Builder Home Page

  • April 29, 2016
  • Like
  • 0