+ Start a Discussion
Amiya Das1410Amiya Das1410 

Displaying Alert/Warning Message on Object Standard Page Layout in Lightning?

I have a scenarion, that when a field value exceeds a particular range , an alert/warning should be displayed. How to display this Alert/Warning Message on Object Standard Page Layout in Lightning?.

Any help will be appreciated
Ajay K DubediAjay K Dubedi
Hi Amiya,

Use this code helpful for you.
 
showWarning : function(component, event, helper) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            title : 'Warning',
            message: 'This is a warning message.',
            duration:' 5000',
            key: 'info_alt',
            type: 'warning',
            mode: 'sticky'
        });
        toastEvent.fire();
    }


Click on the link for more explain:- https://www.biswajeetsamal.com/blog/display-toast-message-in-lighting-component/ (http://https://www.biswajeetsamal.com/blog/display-toast-message-in-lighting-component/)


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
Deepali KulshresthaDeepali Kulshrestha
Hi Amiya,

I've gone through your requirement and you can use the below code for showing error in standard layout:

//visual force page>
<apex:page standardController="Account">
<script>

    window.onload = function(){
    //choose the sobject and field as per your requirement
    
            if('{!Account.Preferred_Language1__c}'=='EN' && '{!Account.Residential_Status__c}'=='Non-resident')
            {
                alert('Warning')
            }
            

    }
</script>
</apex:page>



I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com