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
VRKVRK 

validation rule not display error message in child component in Lighting

Hi ..
I created Validation rule on child component, But when i click on 'Save'(Standard Save)   from Parent component, The Validation rule not display any error message . For this end users confuse and not sure, Whats the problem inside the application 
************************
AND(
OR(
Case_Sold__r.RecordType.Name ='Other1',
Case_Sold__r.RecordType.Name ='Other2'
),
OR(
TEXT(Type__c)= 'emp1',
TEXT(Type__c)= 'emp2',
TEXT(Type__c)= 'emp3'
)
,
ISBLANK(Prior_GA_Number__c)
)
**************
Error message : GA Number cant be blank.
But when i try to save this from Parent compoent , The Error mesage not populating " GA Number cant be blank".

Even i tried Event messages and toast message in Standard ' Save' function , But its not stopping and not display error message 

can you pls assist on this ....its littel bit urgent 
sachinarorasfsachinarorasf
Hi VRK,

If you are using apex to save the record, you can use try-catch block to get the exception, and then sending it to aura back where you can show the error properly. Something like in apex:

try {
    insert/update record;
    return new ResponseWrapper(true, null);
} catch (DMLException dmle) {
    return new ResponseWrapper(false, dmle.getDmlMessage());
}
ResponseWrapper is a wrapper class you can use to send the messages with Boolean success and String message parameters. (Or may be you can send string directly if you are just trying.)
Then in lightning component js callback method parameter (lets say response) you can write:

var message = response.getReturnValue().message;

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

Thanks and Regards,
Sachin Arora
www.sachinsf.com