2

I am creating a lightning component that allows users to create case. The standard UI via page layout is not very user friendly. We have several case types and several standard validation rules. I would like to see if there is anyway I can utilize the standard validation rules for client side validation in my component. I don't think there is but wanted to check. We want to make it admin friendly, Any suggestions on how to let admins manage the validation rules but still provide client side validation in the component?

2

I would recommend you to go through following post: Validating Fields

In given post, methods of error handing in Lightning framework are provided. One of the example is:

<!--c:errorHandlingCustom-->
<aura:component>
    Enter a number: <ui:inputNumber aura:id="inputCmp" onError="{!c.handleError}" onClearErrors="{!c.handleClearError}"/> <br/>
    <ui:button label="Submit" press="{!c.doAction}"/>
</aura:component>

So, by above example you have the way to show and handle errors in Lightning component.

From the controller (Apex) side when user try to save any record which is against the validation rule there will exception so, you can handle that error in try-catch block. Depending on type of exception, lightning component can be rendered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.