• IntroAmmy
  • NEWBIE
  • 40 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 11
    Replies
I have one sceanrio, 

In Account we have more than 1 Opportunity tagged and we are trying to update the one of opprtunity status from Removed to Active and if other opprtunity already present with Active status for this account then it should throw an error and not able to save the record 
can someone please help on that via trigger 
I have seen many article there is no direct way to rename the label of home tab in community site.

can someone please help if any other option we have to change the label 
Need to create opportunity record when x type of account (x is record type) is created and assign contact id of this account to Opportunity account I'd.

can someone help me on that
As per my use case I am creating public group whenever new account is getting created and public group name is followed like Publicgroup-accountId

i am stuck on to update one of account field with public group record Id once public group is created
Can someone please help me on that ?
 
Here is the existing code , when navurl gets call from HTML
method in js
--------------------------
    navUrl(e) {
        var selIndex = e.target.dataset.value;
        window.open(this.allData2Symp[selIndex].docLinks); //its open the document based on link
    }
--------------------------------------------------------------------------------------
trying to change here(instead of navurl menthod created new method handlenavigte- html is same) and trying to pass the link to new component

   handleNavigate(e) {

    var selIndex = e.target.dataset.value;
    //window.open(this.allData2Symp[selIndex].docLinks);
     var link = this.allData2Symp[selIndex].docLinks;   
     //console.log('@@' + selIndex);
           this[NavigationMixin.Navigate]({
               type: 'comm__namedPage',
               attributes: {
                name: 'test__c', // new page created and binded newly created component in page
               },
               state: {
                    c__propertyValue: link
               }                   
            });
       }

new component html where i am passing the link

       <template>
    <video name="media" controls autoplay controlslist="nodownload" width="620" height="640" >
          <source src={link} type="video/mp4">
       </video>       
</template>

new component JS

import { LightningElement, api } from 'lwc';
export default class TargetLwcComponent extends LightningElement {
    @api link;
}

Can someone please help me on that
I need to popluate values from parent record to child record using trigger if the object is same ,
Suppose in Account object(choose Record Type A) i have created and now i am going to create another record(let say child account record) in Account object but this time i have choose the Record Type B
So while i am creating child record some fields need to copy from first account record to child account record [i have created self relationship here]

below is the code 

Trigger PopulatevaluesonChildAccount on Account(Before Insert)
{
    Set<Id> ParentIds = New Set<Id>();

   For(Account A : Trigger.New)
    {
        ParentIds.Add(A.AccountType__c);
    }

   List<Account> ParentList = [Select Id,AccountType__c,name from Account where Id =: ParentIds];
   System.debug(ParentList);
   For(Account ChildAccount : Trigger.New)
    {    
        For(Account ParentAccount : ParentList)
        {
            IF(ChildAccount.AccountType__c == ParentAccount.ID)
                System.debug(Co);
            {
                IF(ParentAccount.Name != NULL)
                {
                    ChildAccount.Name = ParentAccount.Name ;
                    ChildAccount.AccountType__c=ParentAccount.Id;
                   
                }
            }
        }
    }

Can someone please help on that  
If community users created any lead records, after that want to update same lead record(update the value on one field) , is this possible ?
As we have only read and Create access on lead object for community user profile.

Please help me on that..

Thanks,
Hello,
how can we capture locale and timezone of browser and as per specific time need to show text message on same page/or popup(let suppose Record is saved then need to show some message)

Thanks,
I need to add functionality to upload file while i am creating Lead record form Community.
when I create lead from community that file(pdf,jpg, etc) need to be uploaded and associated with same Lead record 

I have tried for existing lead record. it worked , but i have few lead field on my page when i fill the details and upload file the lead shoul be created and file shoud be attached with lead record

Cmp.

<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>  
    <aura:attribute name="files" type="ContentDocument[]"/>  
    <aura:attribute name="recordId" type="string" default="00Q6C00000Pt5kv"/>  
    <aura:attribute name="accept" type="List" default="['.jpg', '.jpeg','.pdf','.csv','.xlsx']"/>  

    <aura:attribute name="multiple" type="Boolean" default="true"/>     
    <aura:attribute name="Spinner" type="boolean" default="false"/>

<div class="slds">  
        <lightning:notificationsLibrary aura:id="notifLib"/>
        <div class="contentbox">  
            <div class="slds-page-header header">Files</div>  
            <div class="slds-grid">  
                <div style="width:100%">  
                    <center>
                        <lightning:fileUpload label="" multiple="{!v.multiple}"   
                                              accept="{!v.accept}" recordId="{!v.recordId}"   
                                              onuploadfinished="{!c.UploadFinished}" />  
                    </center>
                </div>  
            </div><br/> 
            <div class="slds-form--compound" style="position:relative">
                <table class="slds-table slds-table--bordered">  
                    <thead>  
                        <tr>  
                            <th></th>
                            <th>Title</th>  
                            <th>FileType</th>                    
                        </tr>  
                    </thead>  
                    <tbody>
                        <aura:iteration items="{!v.files}" var="f">  
                            <tr>  
                                <td><a href="javascript:void(0)" id="{!f.Id}" onclick="{!c.delFiles}">Delete</a></td>
                                <td><a href="" id="{!f.Id}" onclick="{!c.previewFile}">{!f.Title}</a></td>  
                                <td>{!f.FileType}</td>                              
                            </tr>  
                        </aura:iteration>  
                    </tbody>  
                </table>  
                <aura:if isTrue="{!v.Spinner}">
                    <div class="slds-spinner_container">
                        <div class="slds-spinner slds-spinner--medium" aria-hidden="false" role="alert">
                            <div class="slds-spinner__dot-a"></div>
                            <div class="slds-spinner__dot-b"></div>
                        </div>
                    </div>
                </aura:if>
            </div>
        </div>  
    </div>

Js file.

({
doInit:function(component,event,helper){  
       helper.getuploadedFiles(component);
    }, 
    
    previewFile :function(component,event,helper){  
        var rec_id = event.currentTarget.id;  
        $A.get('e.lightning:openFiles').fire({ 
            recordIds: [rec_id]
        });  
    },
    
        UploadFinished : function(component, event, helper) {  
        var uploadedFiles = event.getParam("files");  
        //var documentId = uploadedFiles[0].documentId;  
        //var fileName = uploadedFiles[0].name; 
        helper.getuploadedFiles(component);         
        component.find('notifLib').showNotice({
            "variant": "info",
            "header": "Success",
            "message": "File Uploaded successfully!!",
            closeCallback: function() {}
        });
    }
})

Apex class

   @AuraEnabled  
    public static List<ContentDocument> getFiles(string recordId){ 
        // TO avoid following exception 
        // System.QueryException: Implementation restriction: ContentDocumentLink requires
        // a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or 
        // multiple Id's using the IN operator.
        // We have to add sigle record id into set or list to make SOQL query call
        Set<Id> recordIds=new Set<Id>{recordId};
        Set<Id> documentIds = new Set<Id>(); 
        List<ContentDocumentLink> cdl = new List<ContentDocumentLink>();
        List<ContentDocument> cd = new List<ContentDocument>();
        cdl= [SELECT id,LinkedEntityId,ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = '0051I000006c7f7QAA'];
        if (!cdl.isEmpty()){
           for(ContentDocumentLink cdLink:cdl){  
            documentIds.add(cdLink.ContentDocumentId);  
        }      
        cd = [SELECT Id,Title,FileType FROM ContentDocument WHERE id IN: documentIds];  
            return cd;
        }
        else
        {
           return cd;
        }

   } 

Can someone plz help me on that
I have created community and added lightning component on that while i am hitting the community url on the same session when i logged in salesforce working fine.
but if i am opening the same url in other browser(not logged with salesforce org) it only showing the page not fetching the picklist values form class on picklist field i mean Apex class not getting called, 
Already added apex class to cummunity profile

can somenone please help me on that
I want to add person image in contact page layout, when contact record is created for that person.
I have tried it via rich text field it is workibg but in rich text field we can not resize the imageas image is showing large so the image should be like as passport size kind of.

Is there any other option how we can do that like add contact image when contact record is created(after contact record creation we just edit the record and add contact image for perticular contact record)
Please see the image which i have added via rich text User-added image
I have created a PB where i am using Task object where i am validatiing a task(let suppose Task XYZ i am creating and Status = completed) so once that task status is completed i need to update few fileds on addess which is associated with this task(In task and address we have accountid field common) using these accountid I need to create a method and invoke via process builder.

Can someone help me on that
I need to add lightning input hidden field with default value "DSP"
When i will save my form with other fields which is in web form this default value will insert in obeject.

<aura:attribute name="dsp" type="String" default="DSP"/>
<lightning:input name="dsp form" value="{!v.leadObj.BIIB_DSP_Form__c}" label="Form"  class="slds-hide"/>

Contrller .js

    doInit: function(cmp) { 
   component.set("v.leadObj.BIIB_DSP_Form__c" ,"DSP");
        var pickvar = cmp.get("c.getPickListValuesIntoList");
        pickvar.setCallback(this, function(response) {
            var state = response.getState();
            if(state === 'SUCCESS'){
                var list = response.getReturnValue();
                cmp.set("v.picvalue", list);
            }
            else if(state === 'ERROR'){
                //var list = response.getReturnValue();
                //component.set("v.picvalue", list);
                alert('ERROR OCCURED.');
            }
        })
        $A.enqueueAction(pickvar);
        
   },

Can someont help me where i am doing wrong
I have created a Flow that is running fine on my UAT, the same flow after deployed on Prod giving error "An error occurred before the scheduled flow <flow name> could run. Contact your Salesforce admin with Error Id 1428821634-23269 (655019316)."

Nothing in debug log, 
In Production its like from the very first step getting failed  
As per the error it is saying before the schedule flow not getting what is happening 

Is there any Release update issue (UAT or Prod environment) or what, can somone please help me out.

Thanks,
Is there any way to accept dd/mm/yyyy format date in lightning component

date field 
               <lightning:input aura:id="birthdate" label="DOB="{!v.leadObj.HealthCloudGA__BirthDate__c}"
                                type="date"  displayDatePicker="true" 
                                 required="true" onchange="{!c.changeDate}" format="mm/dd/yyyy" dateStyle="short" />

I also checked with format="dd/mm/yyyy" its not working it only accepting mm/dd/yyyy
tried also datestyle attribute in component as short but accepting same mm/dd/yyyy

.js
where i am calulating age based on DOB

var birthday = component.find("birthdate").get("v.value");
if(birthday !=null ||  birthday!=undefined)
        {
            var optimizedBirthday = birthday;
        }
        else{
            alert("Enter correct date format");
        }
        
        // it will accept two types of format yyyy-mm-dd and yyyy/mm/dd
        //var optimizedBirthday = birthday.replace(/-/g, "/");
        //set date based on birthday at 01:00:00 hours GMT+0100 (CET)
        var myBirthday = new Date(optimizedBirthday);
        // set current day on 01:00:00 hours GMT+0100 (CET)
        var currentDate = new Date().toJSON().slice(0,10)+' 01:00:00';
        // calculate age comparing current date and borthday
        var myAge = ~~((Date.now(currentDate) - myBirthday) / (31557600000));
        // alert(myAge);

Thanks,
I have created a lightning component to insert lead record in Lead object
Need to write test class for that , i am totally new in test class.
Can someone please help me to write a test class 

attaching my js code and Apex controller

InsertLeadRecordsController.js

({
    save : function(component, event, helper) {  
        var birthday = component.find("birthdate").get("v.value");
        var picl;
        //alert("picl");
        if(component.get("v.FieldsToShow")==true){
            picl = component.find("pic").get("v.value");
        //alert("picl");
        if (picl==='choose'){
            picl='';
            component.set('v.leadObj.BIIB_Relationship_With_Patient__c','');
        }
        }
        if(component.get("v.FieldsToShow")==false){
            component.set('v.leadObj.BIIB_Relationship_With_Patient__c','');
        }
        
        var reqfield1 = component.find("doccrm");
        var reqfield2 = component.find("docname");
        var reqfield3 = component.find("ck");
        var reqfield5 = component.find("fname");
        
        reqfield1.showHelpMessageIfInvalid();
        reqfield2.showHelpMessageIfInvalid();
        reqfield3.showHelpMessageIfInvalid();
        reqfield5.showHelpMessageIfInvalid();
        
        if(!reqfield1.checkValidity() || !reqfield2.checkValidity() || !reqfield3.checkValidity() || !reqfield5.checkValidity() ) {
            // Optional message if you want
            alert("Please fill out the required field."); 
            return; // Don't continue past this point
        }
        
        //To Check Email
        var emailField = component.find("email");
        var emailFieldValue = emailField.get("v.value");
        // Store Regular Expression
        var regExpEmailformat = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        
        if(!$A.util.isEmpty(emailFieldValue)){   
            if(emailFieldValue.match(regExpEmailformat))
            {
                emailField.set("v.errors", [{message: null}]);
                $A.util.removeClass(emailField, 'slds-has-error');                
            }else
            {
                $A.util.addClass(emailField, 'slds-has-error');
                emailField.set("v.errors", [{message: "Please Enter a Valid Email Address"}]);               
            }
        }
        
        if($A.util.isEmpty(component.find("lname").get("v.value"))){
            //component.set("v.hasError", true);
            alert('Last Name is required');
            return false;
        }
        
        if($A.util.isEmpty(component.find("email").get("v.value"))){
            //component.set("v.hasError", true);
            alert('Email is required');
            return false;
        }
        if($A.util.isEmpty(component.find("phone").get("v.value"))){
            //component.set("v.hasError", true);
            alert('Phone is required');
            return false;
        }
        if($A.util.isEmpty(component.find("birthdate").get("v.value"))){
            //component.set("v.hasError", true);
            alert('Birth Date is required');
            return false;
        }
        
        // it will accept two types of format yyyy-mm-dd and yyyy/mm/dd
        var optimizedBirthday = birthday.replace(/-/g, "/");
        //set date based on birthday at 01:00:00 hours GMT+0100 (CET)
        var myBirthday = new Date(optimizedBirthday);
        // set current day on 01:00:00 hours GMT+0100 (CET)
        var currentDate = new Date().toJSON().slice(0,10)+' 01:00:00';
        // calculate age comparing current date and borthday
        var myAge = ~~((Date.now(currentDate) - myBirthday) / (31557600000));
        alert(myAge);
        //var today = $A.localizationService.formatDate(Date.now(currentDate), "YYYY-MM-DD");
        var dateValue = component.get("v.leadObj.HealthCloudGA__BirthDate__c");
        if(dateValue >= currentDate){
            alert('You can not enter grater than today!');
            return false; 
        }

        if(component.get("v.FieldsToShow")==true){

        if (myAge<18 && component.find("Fulname").get("v.value")== undefined) 
        {        
            alert("Full Name Responsible is required");
            return false;  
        }
        if (myAge<18 && component.find("cpfname").get("v.value")== undefined) 
        {        
            alert("CPF Of The Person In charge is required");
            return false;  
        }

        if (myAge<18 && picl==='')
        {
            alert('Please fill the Relationship With Patient');
            return false; 
        }
        if (myAge<18 &&component.find("ck1").get("v.value")== undefined)
        {
            alert('Please Select Declaration Of Legal Responsibility');
            return false; 
        }
        }
        
        if(component.get("v.FieldsToShow1")==true){
            
            if (myAge>18 && component.find("cpfpatient").get("v.value")== undefined) 
            {        
                alert("CPF Patient is required");
                return false;  
            }
        }
    
        
        var action = component.get("c.saveLead");
        action.setParams({"leadObj":component.get("v.leadObj")});
        action.setCallback(this,function(result){
            var state = result.getState();
            if(state === 'SUCCESS'){
                // component.set("v.isShow",false);
                var leadId = result.getReturnValue();
                alert('leadId'+leadId);
                //component.reinit();
                //component.find('form').value = '';
                // component.find("FirstName").set("v.value", '');
                // component.find("birthdate").set("v.value", '');
                //alert('leadId'+leadId);
                
                window.location.href = 'https://hcdev2021-latamchatbot.cs90.force.com/Thankyoupage';
            }
  
        });

        $A.enqueueAction(action);
    },
    doInit: function(cmp) {
        var pickvar = cmp.get("c.getPickListValuesIntoList");
        pickvar.setCallback(this, function(response) {
            var state = response.getState();
            if(state === 'SUCCESS'){
                var list = response.getReturnValue();
                cmp.set("v.picvalue", list);
            }
            else if(state === 'ERROR'){
                //var list = response.getReturnValue();
                //component.set("v.picvalue", list);
                alert('ERROR OCCURED.');
            }
        })
        $A.enqueueAction(pickvar);
        
    },
    
    changeDate : function(component, event, helper) {
        var birthday = component.find("birthdate").get("v.value");
        var optimizedBirthday = birthday.replace(/-/g, "/");
        //set date based on birthday at 01:00:00 hours GMT+0100 (CET)
        var myBirthday = new Date(optimizedBirthday);
        // set current day on 01:00:00 hours GMT+0100 (CET)
        var currentDate = new Date().toJSON().slice(0,10)+' 01:00:00';
        // calculate age comparing current date and borthday
        var myAge = ~~((Date.now(currentDate) - myBirthday) / (31557600000));
        alert(myAge);
        
        if(myAge < 18){
            component.set("v.FieldsToShow",true);    
        }
        else if(myAge > 18){
            component.set("v.FieldsToShow",false);    
        }
        
         if(myAge > 18){
         component.set("v.FieldsToShow1",true);    
        }
         else if(myAge < 18){
         component.set("v.FieldsToShow1",false);    
        }
        
    },
    
    
    handleCheck : function(component, event, helper) {
        var newCheckBoxValue = component.find("ck").get("v.checked");
        component.set('v.leadObj.BIIB_Consent__c',newCheckBoxValue);
        console.log(newCheckBoxValue);
    },
    handleCheck1 : function(component, event, helper) {
        var newCheckBoxValue1 = component.find("ck1").get("v.checked");
        component.set('v.leadObj.BIIB_Declaration_Of_Legal_Responsibility__c',newCheckBoxValue1);
        console.log(newCheckBoxValue1);
    }
})



Apex class(WebToLeadController)

public class WebToLeadController{

@AuraEnabled
public static Id saveLead(Lead leadObj){
System.debug('@' +leadObj);
try{
   insert leadObj;
   }
   catch(exception e){
   AuraHandledException ex = new AuraHandledException(e.getMessage());
    ex.setMessage(e.getMessage());
    throw ex;
   }
   return leadObj.id;
   
}
@AuraEnabled
     
    public static List<String> getPickListValuesIntoList(){
        List<String> pickListValuesList = new List<String>();
        Schema.DescribeFieldResult fieldResult = Lead.BIIB_Relationship_With_Patient__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for( Schema.PicklistEntry pickListVal : ple){
            pickListValuesList.add(pickListVal.getLabel());
            System.debug('Values in Rating are: '+pickListValuesList);
        }     
        return pickListValuesList;
    
    }
}
 
I have created lightning component and 6 fields there, one date field is also there
how can we do that if age is more than 18 years then 2 fields shoud be hide.
Can please someone help me on that...

Thanks in advance
I have created a VF page , can we make it responsive so that it will open in mobile device as user friendly.
menas n need to scroll page left/right side on mobile
I have seen many article there is no direct way to rename the label of home tab in community site.

can someone please help if any other option we have to change the label 
I want to add person image in contact page layout, when contact record is created for that person.
I have tried it via rich text field it is workibg but in rich text field we can not resize the imageas image is showing large so the image should be like as passport size kind of.

Is there any other option how we can do that like add contact image when contact record is created(after contact record creation we just edit the record and add contact image for perticular contact record)
Please see the image which i have added via rich text User-added image
I have created a lightning component to insert lead record in Lead object
Need to write test class for that , i am totally new in test class.
Can someone please help me to write a test class 

attaching my js code and Apex controller

InsertLeadRecordsController.js

({
    save : function(component, event, helper) {  
        var birthday = component.find("birthdate").get("v.value");
        var picl;
        //alert("picl");
        if(component.get("v.FieldsToShow")==true){
            picl = component.find("pic").get("v.value");
        //alert("picl");
        if (picl==='choose'){
            picl='';
            component.set('v.leadObj.BIIB_Relationship_With_Patient__c','');
        }
        }
        if(component.get("v.FieldsToShow")==false){
            component.set('v.leadObj.BIIB_Relationship_With_Patient__c','');
        }
        
        var reqfield1 = component.find("doccrm");
        var reqfield2 = component.find("docname");
        var reqfield3 = component.find("ck");
        var reqfield5 = component.find("fname");
        
        reqfield1.showHelpMessageIfInvalid();
        reqfield2.showHelpMessageIfInvalid();
        reqfield3.showHelpMessageIfInvalid();
        reqfield5.showHelpMessageIfInvalid();
        
        if(!reqfield1.checkValidity() || !reqfield2.checkValidity() || !reqfield3.checkValidity() || !reqfield5.checkValidity() ) {
            // Optional message if you want
            alert("Please fill out the required field."); 
            return; // Don't continue past this point
        }
        
        //To Check Email
        var emailField = component.find("email");
        var emailFieldValue = emailField.get("v.value");
        // Store Regular Expression
        var regExpEmailformat = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        
        if(!$A.util.isEmpty(emailFieldValue)){   
            if(emailFieldValue.match(regExpEmailformat))
            {
                emailField.set("v.errors", [{message: null}]);
                $A.util.removeClass(emailField, 'slds-has-error');                
            }else
            {
                $A.util.addClass(emailField, 'slds-has-error');
                emailField.set("v.errors", [{message: "Please Enter a Valid Email Address"}]);               
            }
        }
        
        if($A.util.isEmpty(component.find("lname").get("v.value"))){
            //component.set("v.hasError", true);
            alert('Last Name is required');
            return false;
        }
        
        if($A.util.isEmpty(component.find("email").get("v.value"))){
            //component.set("v.hasError", true);
            alert('Email is required');
            return false;
        }
        if($A.util.isEmpty(component.find("phone").get("v.value"))){
            //component.set("v.hasError", true);
            alert('Phone is required');
            return false;
        }
        if($A.util.isEmpty(component.find("birthdate").get("v.value"))){
            //component.set("v.hasError", true);
            alert('Birth Date is required');
            return false;
        }
        
        // it will accept two types of format yyyy-mm-dd and yyyy/mm/dd
        var optimizedBirthday = birthday.replace(/-/g, "/");
        //set date based on birthday at 01:00:00 hours GMT+0100 (CET)
        var myBirthday = new Date(optimizedBirthday);
        // set current day on 01:00:00 hours GMT+0100 (CET)
        var currentDate = new Date().toJSON().slice(0,10)+' 01:00:00';
        // calculate age comparing current date and borthday
        var myAge = ~~((Date.now(currentDate) - myBirthday) / (31557600000));
        alert(myAge);
        //var today = $A.localizationService.formatDate(Date.now(currentDate), "YYYY-MM-DD");
        var dateValue = component.get("v.leadObj.HealthCloudGA__BirthDate__c");
        if(dateValue >= currentDate){
            alert('You can not enter grater than today!');
            return false; 
        }

        if(component.get("v.FieldsToShow")==true){

        if (myAge<18 && component.find("Fulname").get("v.value")== undefined) 
        {        
            alert("Full Name Responsible is required");
            return false;  
        }
        if (myAge<18 && component.find("cpfname").get("v.value")== undefined) 
        {        
            alert("CPF Of The Person In charge is required");
            return false;  
        }

        if (myAge<18 && picl==='')
        {
            alert('Please fill the Relationship With Patient');
            return false; 
        }
        if (myAge<18 &&component.find("ck1").get("v.value")== undefined)
        {
            alert('Please Select Declaration Of Legal Responsibility');
            return false; 
        }
        }
        
        if(component.get("v.FieldsToShow1")==true){
            
            if (myAge>18 && component.find("cpfpatient").get("v.value")== undefined) 
            {        
                alert("CPF Patient is required");
                return false;  
            }
        }
    
        
        var action = component.get("c.saveLead");
        action.setParams({"leadObj":component.get("v.leadObj")});
        action.setCallback(this,function(result){
            var state = result.getState();
            if(state === 'SUCCESS'){
                // component.set("v.isShow",false);
                var leadId = result.getReturnValue();
                alert('leadId'+leadId);
                //component.reinit();
                //component.find('form').value = '';
                // component.find("FirstName").set("v.value", '');
                // component.find("birthdate").set("v.value", '');
                //alert('leadId'+leadId);
                
                window.location.href = 'https://hcdev2021-latamchatbot.cs90.force.com/Thankyoupage';
            }
  
        });

        $A.enqueueAction(action);
    },
    doInit: function(cmp) {
        var pickvar = cmp.get("c.getPickListValuesIntoList");
        pickvar.setCallback(this, function(response) {
            var state = response.getState();
            if(state === 'SUCCESS'){
                var list = response.getReturnValue();
                cmp.set("v.picvalue", list);
            }
            else if(state === 'ERROR'){
                //var list = response.getReturnValue();
                //component.set("v.picvalue", list);
                alert('ERROR OCCURED.');
            }
        })
        $A.enqueueAction(pickvar);
        
    },
    
    changeDate : function(component, event, helper) {
        var birthday = component.find("birthdate").get("v.value");
        var optimizedBirthday = birthday.replace(/-/g, "/");
        //set date based on birthday at 01:00:00 hours GMT+0100 (CET)
        var myBirthday = new Date(optimizedBirthday);
        // set current day on 01:00:00 hours GMT+0100 (CET)
        var currentDate = new Date().toJSON().slice(0,10)+' 01:00:00';
        // calculate age comparing current date and borthday
        var myAge = ~~((Date.now(currentDate) - myBirthday) / (31557600000));
        alert(myAge);
        
        if(myAge < 18){
            component.set("v.FieldsToShow",true);    
        }
        else if(myAge > 18){
            component.set("v.FieldsToShow",false);    
        }
        
         if(myAge > 18){
         component.set("v.FieldsToShow1",true);    
        }
         else if(myAge < 18){
         component.set("v.FieldsToShow1",false);    
        }
        
    },
    
    
    handleCheck : function(component, event, helper) {
        var newCheckBoxValue = component.find("ck").get("v.checked");
        component.set('v.leadObj.BIIB_Consent__c',newCheckBoxValue);
        console.log(newCheckBoxValue);
    },
    handleCheck1 : function(component, event, helper) {
        var newCheckBoxValue1 = component.find("ck1").get("v.checked");
        component.set('v.leadObj.BIIB_Declaration_Of_Legal_Responsibility__c',newCheckBoxValue1);
        console.log(newCheckBoxValue1);
    }
})



Apex class(WebToLeadController)

public class WebToLeadController{

@AuraEnabled
public static Id saveLead(Lead leadObj){
System.debug('@' +leadObj);
try{
   insert leadObj;
   }
   catch(exception e){
   AuraHandledException ex = new AuraHandledException(e.getMessage());
    ex.setMessage(e.getMessage());
    throw ex;
   }
   return leadObj.id;
   
}
@AuraEnabled
     
    public static List<String> getPickListValuesIntoList(){
        List<String> pickListValuesList = new List<String>();
        Schema.DescribeFieldResult fieldResult = Lead.BIIB_Relationship_With_Patient__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for( Schema.PicklistEntry pickListVal : ple){
            pickListValuesList.add(pickListVal.getLabel());
            System.debug('Values in Rating are: '+pickListValuesList);
        }     
        return pickListValuesList;
    
    }
}
 
I have created lightning component and 6 fields there, one date field is also there
how can we do that if age is more than 18 years then 2 fields shoud be hide.
Can please someone help me on that...

Thanks in advance
How can i throw error msg via apex if i have a field name birthdate in vf page and if birthdate is less than 18 years it throw error while i am saving record ..
Can somenone please help.

Thanks,