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
Nagaraja SV 12Nagaraja SV 12 

Display an “ Saved” Message

How to show success message after record successfully saved to server.

 

Best Answer chosen by Nagaraja SV 12
Balasubramaniam 07Balasubramaniam 07
Hi Naga,

Please try this
 
<aura:attribute name="status" type="String"/>
 <aura:attribute name="showSuccess" type="boolean" default="false"></aura:attribute> 
 <aura:if isTrue="{!v.showSuccess}"> 
    <div class="slds-notify_container">
        <div class="slds-notify slds-notify--toast slds-theme--success" role="alert">
            <span class="slds-assistive-text">Success</span>    
            
            <div class="notify__content slds-grid">                       
                <span class="slds-icon__container ">
                    <c:SVG class="slds-icon slds-icon--small slds-m-right--small slds-col slds-no-flex" xlinkHref="/resource/slds/assets/icons/utility-sprite/svg/symbols.svg#notification" />
                    <span class="slds-assistive-text">Alert</span>
                </span>
                <div class="slds-col slds-align-middle">
                    <h2 class="slds-text-heading--small ">{!v.status}</h2>
                </div>
            </div>
        </div>
    </div>
 </aura:if>


 controller
 
 after getting succesful result 
component.set("v.showSuccess", true);
component.set("v.status", result);

 

All Answers

Sumit Kumar Singh 9Sumit Kumar Singh 9
Hello Nag,

Please, go through the following link-
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_database.htm
Code snapshot taken from the above link -
// Create the list of sObjects to insert
List<Account> acctList = new List<Account>();
acctList.add(new Account(Name='Acme1'));
acctList.add(new Account(Name='Acme2'));

// DML statement
Database.SaveResult[] srList = Database.insert(acctList, false);

// Iterate through each returned result
for (Database.SaveResult sr : srList) {
    if (sr.isSuccess()) {
        // Operation was successful, so get the ID of the record that was processed
        System.debug('Successfully inserted account. Account ID: ' + sr.getId());
    }
    else {
        // Operation failed, so get all errors                
        for(Database.Error err : sr.getErrors()) {
            System.debug('The following error has occurred.');                    
            System.debug(err.getStatusCode() + ': ' + err.getMessage());
            System.debug('Account fields that affected this error: ' + err.getFields());
        }
    }
}
Hope this will help you.

Thanks,
Sumit Kumar Singh
Nagaraja SV 12Nagaraja SV 12
Thank you for your quick response .

I need to display message in lightening component.
Balasubramaniam 07Balasubramaniam 07
Hi Naga,

Please try this
 
<aura:attribute name="status" type="String"/>
 <aura:attribute name="showSuccess" type="boolean" default="false"></aura:attribute> 
 <aura:if isTrue="{!v.showSuccess}"> 
    <div class="slds-notify_container">
        <div class="slds-notify slds-notify--toast slds-theme--success" role="alert">
            <span class="slds-assistive-text">Success</span>    
            
            <div class="notify__content slds-grid">                       
                <span class="slds-icon__container ">
                    <c:SVG class="slds-icon slds-icon--small slds-m-right--small slds-col slds-no-flex" xlinkHref="/resource/slds/assets/icons/utility-sprite/svg/symbols.svg#notification" />
                    <span class="slds-assistive-text">Alert</span>
                </span>
                <div class="slds-col slds-align-middle">
                    <h2 class="slds-text-heading--small ">{!v.status}</h2>
                </div>
            </div>
        </div>
    </div>
 </aura:if>


 controller
 
 after getting succesful result 
component.set("v.showSuccess", true);
component.set("v.status", result);

 
This was selected as the best answer
Nagaraja SV 12Nagaraja SV 12

Hi
Balasubramaniam 

Thank you so much..