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
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
Aleksandar Basic 12Aleksandar Basic 12
Check out Alerts - Soft Validation Rules on the AppExchange. (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000IkzfzUAB&tab=d) 
Combined with the chrome extension, you can configure "soft validation rules" which display pop ups on standard record edit forms if the conditions are met.