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
Sisodia SaurabhSisodia Saurabh 

Need to validate fields on default details tab then redirect to new page using Lightning component

Hi All,
I need to validate couple of fields from details tab of a case. if fields are not empty/null then Click on the component button to redirect the page. I know the 2nd part of redirecting but I want to know how can I validate fields on the component click.

Below is the logic which I was trying but I am pretty sure it is not correct way:

caseValidation : function(component, event, helper){
          var caseId = component.get("v.recordId");
      var action = component.get("c.caseValidationList");
            Id : caseId
        action.setCallback(this, function(response){ 
            var state = response.getState();
            var  cv = response.getReturnValue();
            var csonevar;
            if (state === "SUCCESS") {
               for(var c in cv)
                       csonevar = c.CSOne_Case_Number__c; 
Classe returning query
    public static list<case> caseValidationList(Id Id)
        List<case> cc = new List<case>();
        if(Id != null || Id != '')
           cc = [Select CSOne_Case_Number__c, OwnerIsQueue__c,Status from case where Id=: Id];
        return cc;

Thanks in advance

Amit Singh 1Amit Singh 1
Hi ,
Refer the below link

Also, you can use $A.utility class to validate the fields and return true or false based on the values into the attributes.