• noor Zabi
  • NEWBIE
  • 30 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 8
    Replies
Hello, 
I am not able to navigate a page in community via lightning components.
In salesforce community pages name is Signup and Login
One components name: - SignupPage.cmp
Two components name: -  LoginPage.cmp


SignupPage.cmp:
<aura:component implements="force:appHostable,lightning:isUrlAddressable, flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    <aura:attribute name="signObj" type="String" default="{'sobjecttypr':'Lead'}"/>
    <aura:attribute name="Name" type="String" default="" />
<lightning:button label="Login" variant="brand-outline" class="slds-m-top_small" onclick="{!c.dologin}"></lightning:button>

</aura:component>

Controller: - 
dologin : function(component, event, helper) {
         
        let navLogins = component.find("navLogins");
        
        let pageReferences = {
            
                type: "comm__namedPage",
                attributes: {
                    name: "Login"
    
            
        }};
         navLogins.navigate(pageReferences);
    
}
            I'm getting invalid page in salesforce community.
User-added image
I am not able insert a record in opprotunity object via lightnig components. I don't where i going wrong. 

Component: -
<aura:component controller="BookingController"  implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"  access="global">

    
<aura:attribute name="BookObj" type="String" default="{'sobjecttype' : 'Opportunity'}"/>
<aura:attribute name="StaffId" type="String"/>  
<aura:attribute name="Name" type="String" default=""/>
<aura:attribute name="BookingDate" type="Date" default=""/>
<aura:attribute name="Kilometer" type="String" default=""/>
<aura:attribute name="Pickup" type="String" default=""/>
<aura:attribute name="Drop" type="String" default=""/>
<aura:attribute name="Cab" type="String"/>
<aura:attribute name="SelectPayment" type="String[]" default=""/>
<aura:attribute name="AcctId" type="String" default="Account[]"/>
<aura:attribute name="DriverId" type="String" default="Employee_Information__c"/>
    <aura:attribute name="Stage" type="String" default="New"/>

<br/>
<div class="slds-page-header">
        <div class="slds-align_absolute-center">
            <div class="slds-text-heading_large">
                <div class="slds-m-top_xx-large">
                    Booking Cab
                </div>
            </div>
        </div>
    </div>
    
<br/>
<lightning:recordEditForm aura:id="recordEditForm" objectApiName="Opportunity">
    <lightning:messages/>
    <lightning:inputField fieldName="Name" type="String" value="{!v.Name}"/>
    <lightning:inputField fieldName="CloseDate" type="Date"  value="{!v.BookObj.BookingDate}"/>
    <lightning:inputField fieldName="Pickup_Location__c" type="String" value="{!v.BookObj.Pickup}"/>
    <lightning:inputField fieldName="Dropping_Location__c" type="String" value="{!v.BookObj.Drop}"/>
    <lightning:inputField fieldName="Kilometer__c" type="String" value="{!v.BookObj.Kilometer}"/>
    <lightning:inputField fieldName="Select_Option__c" type="String" value="{!v.BookObj.Cab}"/>
    <lightning:inputField fieldName="Select_Payment__c" type="String" value="{!v.BookObj.SelectPayment}"/>
    <lightning:inputField label="Customer id" fieldName="AccountId"  type="String" selectedRecord="{!v.BookObj.AccntId}"/>
    <lightning:inputField fieldName="Driver__c" selectedRecord="{!v.BookObj.AccntId}" type="String" required="true"/>
    <lightning:inputField fieldName="StageName"  value="{!v.BookObj.Stage}"/>
</lightning:recordEditForm>

<lightning:button label="Book" onclick="{!c.doBook}"></lightning:button>
</aura:component>

Controller: -

({
  doBook : function(component, event, helper) { 
    var action = component.get("c.SaveRecord");
    action.setParams({ 
        "Opp": component.get("v.BookObj")
    });
    action.setCallback(this, function(a) {
           var state = a.getState();
            if (state === "SUCCESS") {
                var name = a.getReturnValue();
               alert("hello from here"+Name);
            }
        });
    $A.enqueueAction(action)
}
})


Apex Class: -
public with sharing class BookingController {
    
    @AuraEnabled
    public static Opportunity SaveRecord(Opportunity oppObj){
         System.debug('opportunity::' +oppObj.Name);
        insert oppObj;
        return oppObj;
        
    }
}
I have create a Visual force page in that i want to create a button called 'sign Up'.
  • That button should navigate to lightning Components.
  • Component Name: - 'SignupPage'.

I try many thing i not getting to redirect into lightning components.
/* eslint-disable no-debugger */
/* eslint-disable @lwc/lwc/no-async-operation */
import { LightningElement, track, api } from "lwc";
import { Card } from "./card";
import { Payment } from "./payment";
export default class CardInput extends LightningElement {
  @api paymentMethod = "Credit/Dedit Card";
  @track paymentOptions = [
    { label: "Credit/Dedit Card", value: "Credit/Dedit Card", selected: true },
    { label: "PayPal", value: "PayPal" }];
  @track card;
  @track valid = false;
  @track cardNumberValid = false;
  @track cardHolderNameValid = false;
  @track cardExpiryValid = false;
  @track cardCVCValid = false;
  @track cardNumberTouched = false;
  @track cardHolderNameTouched = false;
  @track cardExpiryTouched = false;
  @track cardCVCTouched = false;
  @track cardNumber = "";
  @track cardHolderName = "";
  @track cardExpiry = "";
  @track cardCVC = "";
  connectedCallback() {
    //copy public attributes to private ones
    var self = this;
    //debugger;
    window.setTimeout(() => {
      self.card = new Card({
        //reference to this object so will work with web components
        context: self,
        // a selector or DOM element for the form where users will
        // be entering their information
        form: self.template.querySelector(".cc-input"),
        // a selector or DOM element for the container
        // where you want the card to appear
        container: ".cc-wrapper", // *required*
        width: 250, // optional — default 350px
        formatting: true, // optional - default true
        // Strings for translation - optional
        messages: {
          validDate: "valid\ndate", // optional - default 'valid\nthru'
          monthYear: "mm/yyyy" // optional - default 'month/year'
        },
        // Default placeholders for rendered fields - optional
        placeholders: {
          number: "•••• •••• •••• ••••",
          name: "Full Name",
          expiry: "••/••",
          cvc: "•••"
        },
        masks: {
          cardNumber: "•" // optional - mask card number
        },
        // if true, will log helpful messages for setting up Card
        debug: true // optional - default false
      });
    }, 50);
  }
  handleCCInput(event) {
    this.cardNumber = event.target.value;
    this.cardNumberValid = this.getIsValid(this.cardNumber, "cardNumber");
    this.cardNumberTouched = true;
    this.showFeedback();
    this.checkIfComplete();
  }
  handleNameInput(event) {
    this.cardHolderName = event.target.value;
    this.cardHolderNameValid = this.getIsValid(this.cardHolderName, "cardHolderName");
    this.cardHolderNameTouched = true;
    this.showFeedback();
    this.checkIfComplete();
  }
  handleExpiryInput(event) {
    this.cardExpiry = event.target.value;
    this.cardExpiryValid = this.getIsValid(this.cardExpiry, "cardExpiry");
    this.cardExpiryTouched = true;
    this.showFeedback();
    this.checkIfComplete();
  }
  handleCVVInput(event) {
    this.cardCVC = event.target.value;
    this.cardCVCValid = this.getIsValid(this.cardCVC, "cardCVC");
    this.cardCVCTouched = true;
    this.showFeedback();
    this.checkIfComplete();
  }
  showFeedback() {
    if (!this.cardNumberValid && this.cardNumberTouched) {
      //show error label
      this.template.querySelectorAll(".cardNumberError")[0].classList.remove("slds-hide");
      this.template.querySelectorAll(".cardNumberFormElement")[0].classList.add("slds-has-error");
    } else {
      this.template.querySelectorAll(".cardNumberError")[0].classList.add("slds-hide");
      this.template
        .querySelectorAll(".cardNumberFormElement")[0]
        .classList.remove("slds-has-error");
    }
    if (!this.cardHolderNameValid && this.cardHolderNameTouched) {
      //show error label
      this.template.querySelectorAll(".cardNameError")[0].classList.remove("slds-hide");
      this.template.querySelectorAll(".cardNameFormElement")[0].classList.add("slds-has-error");
    } else {
      this.template.querySelectorAll(".cardNameError")[0].classList.add("slds-hide");
      this.template.querySelectorAll(".cardNameFormElement")[0].classList.remove("slds-has-error");
    }
    if (!this.cardExpiryValid && this.cardExpiryTouched) {
      //show error label
      this.template.querySelectorAll(".cardExpiryError")[0].classList.remove("slds-hide");
      this.template.querySelectorAll(".cardExpiryFormElement")[0].classList.add("slds-has-error");
    } else {
      this.template.querySelectorAll(".cardExpiryError")[0].classList.add("slds-hide");
      this.template
        .querySelectorAll(".cardExpiryFormElement")[0]
        .classList.remove("slds-has-error");
    }
    if (!this.cardCVCValid && this.cardCVCTouched) {
      //show error label
      this.template.querySelectorAll(".cardCVVError")[0].classList.remove("slds-hide");
      this.template.querySelectorAll(".cardCVVFormElement")[0].classList.add("slds-has-error");
    } else {
      this.template.querySelectorAll(".cardCVVError")[0].classList.add("slds-hide");
      this.template.querySelectorAll(".cardCVVFormElement")[0].classList.remove("slds-has-error");
    }
  }
  //this syntax means we should be able to leave off 'this'
  checkIfComplete = () => {
    if (
      this.cardNumberValid &&
      this.cardHolderNameValid &&
      this.cardExpiryValid &&
      this.cardCVCValid
    ) {
      //send a message
      const detail = {
        type: "cardComplete",
        value: {
          cardNumber: this.cardNumber,
          cardHolderName: this.cardHolderName,
          cardCVV: this.cardCVC,
          cardExpiry: this.cardExpiry,
          cardType: this.card.cardType
        }
      };
      this.despatchCompleteEvent(detail);
    } else {
      // LCC.sendMessage({ type: 'cardIncomplete' });
      this.despatchIncompleteEvent();
    }
  };
  despatchCompleteEvent(cardData) {
    const changeEvent = new CustomEvent("cardComplete", { detail: cardData });
    this.dispatchEvent(changeEvent);
  }
  despatchIncompleteEvent() {
    const changeEvent = new CustomEvent("cardIncomplete", { detail: {} });
    this.dispatchEvent(changeEvent);
  }
  handlePaymentMethodChange(event) {
    const selectedMethod = event.detail.value;
    const changeEvent = new CustomEvent("paymentMethodChange", {
      detail: { paymentMethod: selectedMethod }
    });
    this.dispatchEvent(changeEvent);
  }
  //this syntax means we should be able to leave off 'this'
  getIsValid = (val, validatorName) => {
    var isValid, objVal;
    if (validatorName === "cardExpiry") {
      objVal = Payment.fns.cardExpiryVal(val);
      isValid = Payment.fns.validateCardExpiry(objVal.month, objVal.year);
    } else if (validatorName === "cardCVC") {
      isValid = Payment.fns.validateCardCVC(val, this.card.cardType);
    } else if (validatorName === "cardNumber") {
      isValid = Payment.fns.validateCardNumber(val);
    } else if (validatorName === "cardHolderName") {
      isValid = val !== "";
    }
    return isValid;
  };
}
 
Error getting: -Cannot find Lightning Component Bundle CardInput.                             
 Cannot find Lightning Component Bundle CardInput.                             
duplicate value found: <unknown> duplicates value on record with id: <unknown>
Hi, 
  There any way to converted lead record by sales executive and than create a report on converted.

How we can create a sales executive for lead, account, opportunity and cases.
VIsual Force Page:-
<apex:page controller="StudentController">
  <apex:form id="test" >
<apex:pageMessages/>
      <apex:pageBlock title="Choose the Object To Create Records:" >   
       <center>
          <apex:selectList value="{!source}" size="1" required="true" >
              <apex:selectOptions value="{!sourceValue}" />
              <apex:actionSupport event="onchange" action="{!objectDisplay}" reRender="test"/>
          </apex:selectList> 
       </center>   
      </apex:pageBlock>
      <apex:pageBlock rendered="{!flag}">   
          <apex:pageBlockSection title="Create Student Details" columns="1" >
           
            <apex:inputField value="{!stu1.Salutation__c}" required="true"/>
            <apex:inputField value="{!stu1.Name}" required="true"/>
            <apex:inputField value="{!stu1.Last_Name__c}" required="true"/>
            <apex:inputField value="{!stu1.Gender__c}"  required="true"/>
            <apex:inputField value="{!stu1.DOB__c}"  required="true"/>
            <apex:inputField value="{!stu1.Class__c}"  required="true"/>
            <apex:inputField value="{!stu1.Division__c}" required="true"/>
              
          </apex:pageBlockSection>         
     </apex:pageBlock>
       <apex:pageBlock rendered="{!flag1}">        
          <apex:pageBlockSection title="Create Teacher Details" columns="2" >
          
            <apex:inputField value="{!tch1.Salutation__c}" required="true" />
            <apex:inputField value="{!tch1.Name}" required="true"/>
            <apex:inputField value="{!tch1.Last_Name__c}"  required="true"/>
            <apex:inputField value="{!tch1.Gender__c}" required="true"/>
            <apex:inputField value="{!tch1.DOB__c}" required="true"/>
            <apex:inputField value="{!tch1.Class__c}"  required="true"/>
            <apex:inputField value="{!tch1.Division__c}" required="true" />

          </apex:pageBlockSection>
         
      </apex:pageBlock>
      <apex:pageBlock rendered="{!flag2}">
        <apex:pageBlockSection>
            <apex:commandButton value="Save" action="{!SaveRecord}" />
            <apex:commandButton value="Clear" action="{!clearFunction}" />
        </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

Class:--

public with sharing class StudentController {
    public string source {get;set;}
    public List<selectOption> sourceValue {get;set;}
    public boolean flag {get;set;}
    public boolean flag1 {get;set;}
    public boolean flag2 {get;set;}
    public Students__c stu1{get;set;}
    public Teacher__c tch1{get;set;}
    
    
    public StudentController()
    {
        flag = false;
        flag1 = false;
        flag2 = false;
        stu1 = new Students__c();
        tch1 = new Teacher__c();
        sourceValue = new List<selectOption>();
        sourceValue.add(new selectOption('','--select--'));
        sourceValue.add(new selectOption('Students','Students'));
        sourceValue.add(new selectOption('Teacher','Teacher'));
    }
    
    public void objectDisplay()
    { 
         If(source == 'Students'){
            flag = true;
            flag2= true;
            flag1 = false;
        }
        else if(source == 'Teacher'){
            flag1 = true;
            flag2= true;
            flag = false;
        }
    }
    public void saveRecord() {
        if(source=='Students') {
        insert stu1;
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,' Record Created Successfully.Thank you!'));
        stu1 = new Students__c();
        }
        else {
            insert tch1;
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,' Record Created Successfully.Thank you!'));
            tch1 = new Teacher__c();
        }
    }
    public void clearFunction(){
        if(source=='Students') {
        stu1 = new Students__c();
        }
        else{
        tch1 = new Teacher__c();
        }
    }
}

When i  use required = true  in input fields it is working, but i change theUser-added image select option from student to teacher or teacher to student. I'm getting this error
 
Components:--

<aura:component controller="Staffbutton" implements="lightning:availableForFlowActions, force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
       
    <aura:attribute name="Staffbutton" type="string"/>
    <aura:attribute name="StaffdId" type="String"/>  
<lightning:button label="Success" variant="brand"
         onclick="{!c.displaymsg}"/>
    </div>
</aura:component>

Controller:-
displaymsg: function (component, event, helper) {
         var toastEvent = $A.get("e.force:showToast");
            //fire the toast event in Salesforce app and Lightning Experience
            toastEvent.setParams({
                "title": "Success!",
                "type": "success",
                "mode": 'dismissable',
                "message": "The component successfully load."+component.get('v.recordId')
            });
            toastEvent.fire();
    
    
            }})



I'm not unable display record Id with toast message.

I'm getting this one..User-added image
trigger OpportunityTrigger on Opportunity (before update, after insert, after update, after delete, after undelete) {
    //trigger.oldMap --> Map<Id,Opportunity>
    if(Trigger.isBefore){
    for(Opportunity opp: Trigger.new) {
        if(Trigger.oldMap.get(opp.Id).StageName == 'Closed Won') {
            opp.addError('You cannot modified the opportunity when stage is Closed Won.');                                
        }
    }    }
    else{
        OpportunityTriggerHandler.rollupV3();

    }}



rollupV3:- Contact Trigger Handler

public static void rollup_v3(){
            Set<Id> accIds = getAccIds();
            List<Account> accLst = new List<Account>();
            for(AggregateResult agg : [SELECT AccountId, Count(Id)  FROM Contact 
            WHERE AccountId in: accIds AND MailingCountry != 'USA'GROUP BY AccountId]) {
                Id accId = (Id)agg.get('AccountId');
                Account acc = new Account(
                    Id= accId,
                    Number_of_non_USA_contact__c = (Integer)agg.get('expr0')
                    
                );
                accLst.add(acc);
                accIds.remove(accId);
                
            }
            //To fix the last but USA contact deleted or update to other country
            if(accIds.size() > 0) {
                for(Id accId : accIds) {
                    Account acc = new Account(
                        Id = accId,
                        Number_of_non_USA_contact__c = 0
        );
        accLst.add(acc);
    }
}

        if(accLst.size() > 0)
             update accLst;
        }

        public static Set<Id> getAccIds(){

            //trigger.new---> List<sObject>
        List<Contact> triggerOld = (List<Contact>)Trigger.old;
        List<Contact> triggerNew = (List<Contact>)Trigger.new;
        

        //Collect the account ids to update
        Set<Id> accIds = new Set<Id>();
        for(Contact con: trigger.isDelete ? triggerOld: triggerNew){
            accIds.add(con.AccountId);
        }
        System.debug('accIds: ' + accIds);
        return accIds;
        }


Test Class:

@isTest
public class ContactTriggerTest {
    @isTest Public Static void myTest(){
        Contact con = new Contact();
        test.startTest();
        Delete con; Insert con; Undelete con; Update con;
        test.stopTest();
        
    }
}
/* eslint-disable no-debugger */
/* eslint-disable @lwc/lwc/no-async-operation */
import { LightningElement, track, api } from "lwc";
import { Card } from "./card";
import { Payment } from "./payment";
export default class CardInput extends LightningElement {
  @api paymentMethod = "Credit/Dedit Card";
  @track paymentOptions = [
    { label: "Credit/Dedit Card", value: "Credit/Dedit Card", selected: true },
    { label: "PayPal", value: "PayPal" }];
  @track card;
  @track valid = false;
  @track cardNumberValid = false;
  @track cardHolderNameValid = false;
  @track cardExpiryValid = false;
  @track cardCVCValid = false;
  @track cardNumberTouched = false;
  @track cardHolderNameTouched = false;
  @track cardExpiryTouched = false;
  @track cardCVCTouched = false;
  @track cardNumber = "";
  @track cardHolderName = "";
  @track cardExpiry = "";
  @track cardCVC = "";
  connectedCallback() {
    //copy public attributes to private ones
    var self = this;
    //debugger;
    window.setTimeout(() => {
      self.card = new Card({
        //reference to this object so will work with web components
        context: self,
        // a selector or DOM element for the form where users will
        // be entering their information
        form: self.template.querySelector(".cc-input"),
        // a selector or DOM element for the container
        // where you want the card to appear
        container: ".cc-wrapper", // *required*
        width: 250, // optional — default 350px
        formatting: true, // optional - default true
        // Strings for translation - optional
        messages: {
          validDate: "valid\ndate", // optional - default 'valid\nthru'
          monthYear: "mm/yyyy" // optional - default 'month/year'
        },
        // Default placeholders for rendered fields - optional
        placeholders: {
          number: "•••• •••• •••• ••••",
          name: "Full Name",
          expiry: "••/••",
          cvc: "•••"
        },
        masks: {
          cardNumber: "•" // optional - mask card number
        },
        // if true, will log helpful messages for setting up Card
        debug: true // optional - default false
      });
    }, 50);
  }
  handleCCInput(event) {
    this.cardNumber = event.target.value;
    this.cardNumberValid = this.getIsValid(this.cardNumber, "cardNumber");
    this.cardNumberTouched = true;
    this.showFeedback();
    this.checkIfComplete();
  }
  handleNameInput(event) {
    this.cardHolderName = event.target.value;
    this.cardHolderNameValid = this.getIsValid(this.cardHolderName, "cardHolderName");
    this.cardHolderNameTouched = true;
    this.showFeedback();
    this.checkIfComplete();
  }
  handleExpiryInput(event) {
    this.cardExpiry = event.target.value;
    this.cardExpiryValid = this.getIsValid(this.cardExpiry, "cardExpiry");
    this.cardExpiryTouched = true;
    this.showFeedback();
    this.checkIfComplete();
  }
  handleCVVInput(event) {
    this.cardCVC = event.target.value;
    this.cardCVCValid = this.getIsValid(this.cardCVC, "cardCVC");
    this.cardCVCTouched = true;
    this.showFeedback();
    this.checkIfComplete();
  }
  showFeedback() {
    if (!this.cardNumberValid && this.cardNumberTouched) {
      //show error label
      this.template.querySelectorAll(".cardNumberError")[0].classList.remove("slds-hide");
      this.template.querySelectorAll(".cardNumberFormElement")[0].classList.add("slds-has-error");
    } else {
      this.template.querySelectorAll(".cardNumberError")[0].classList.add("slds-hide");
      this.template
        .querySelectorAll(".cardNumberFormElement")[0]
        .classList.remove("slds-has-error");
    }
    if (!this.cardHolderNameValid && this.cardHolderNameTouched) {
      //show error label
      this.template.querySelectorAll(".cardNameError")[0].classList.remove("slds-hide");
      this.template.querySelectorAll(".cardNameFormElement")[0].classList.add("slds-has-error");
    } else {
      this.template.querySelectorAll(".cardNameError")[0].classList.add("slds-hide");
      this.template.querySelectorAll(".cardNameFormElement")[0].classList.remove("slds-has-error");
    }
    if (!this.cardExpiryValid && this.cardExpiryTouched) {
      //show error label
      this.template.querySelectorAll(".cardExpiryError")[0].classList.remove("slds-hide");
      this.template.querySelectorAll(".cardExpiryFormElement")[0].classList.add("slds-has-error");
    } else {
      this.template.querySelectorAll(".cardExpiryError")[0].classList.add("slds-hide");
      this.template
        .querySelectorAll(".cardExpiryFormElement")[0]
        .classList.remove("slds-has-error");
    }
    if (!this.cardCVCValid && this.cardCVCTouched) {
      //show error label
      this.template.querySelectorAll(".cardCVVError")[0].classList.remove("slds-hide");
      this.template.querySelectorAll(".cardCVVFormElement")[0].classList.add("slds-has-error");
    } else {
      this.template.querySelectorAll(".cardCVVError")[0].classList.add("slds-hide");
      this.template.querySelectorAll(".cardCVVFormElement")[0].classList.remove("slds-has-error");
    }
  }
  //this syntax means we should be able to leave off 'this'
  checkIfComplete = () => {
    if (
      this.cardNumberValid &&
      this.cardHolderNameValid &&
      this.cardExpiryValid &&
      this.cardCVCValid
    ) {
      //send a message
      const detail = {
        type: "cardComplete",
        value: {
          cardNumber: this.cardNumber,
          cardHolderName: this.cardHolderName,
          cardCVV: this.cardCVC,
          cardExpiry: this.cardExpiry,
          cardType: this.card.cardType
        }
      };
      this.despatchCompleteEvent(detail);
    } else {
      // LCC.sendMessage({ type: 'cardIncomplete' });
      this.despatchIncompleteEvent();
    }
  };
  despatchCompleteEvent(cardData) {
    const changeEvent = new CustomEvent("cardComplete", { detail: cardData });
    this.dispatchEvent(changeEvent);
  }
  despatchIncompleteEvent() {
    const changeEvent = new CustomEvent("cardIncomplete", { detail: {} });
    this.dispatchEvent(changeEvent);
  }
  handlePaymentMethodChange(event) {
    const selectedMethod = event.detail.value;
    const changeEvent = new CustomEvent("paymentMethodChange", {
      detail: { paymentMethod: selectedMethod }
    });
    this.dispatchEvent(changeEvent);
  }
  //this syntax means we should be able to leave off 'this'
  getIsValid = (val, validatorName) => {
    var isValid, objVal;
    if (validatorName === "cardExpiry") {
      objVal = Payment.fns.cardExpiryVal(val);
      isValid = Payment.fns.validateCardExpiry(objVal.month, objVal.year);
    } else if (validatorName === "cardCVC") {
      isValid = Payment.fns.validateCardCVC(val, this.card.cardType);
    } else if (validatorName === "cardNumber") {
      isValid = Payment.fns.validateCardNumber(val);
    } else if (validatorName === "cardHolderName") {
      isValid = val !== "";
    }
    return isValid;
  };
}
 
Error getting: -Cannot find Lightning Component Bundle CardInput.                             
 Cannot find Lightning Component Bundle CardInput.                             
duplicate value found: <unknown> duplicates value on record with id: <unknown>
VIsual Force Page:-
<apex:page controller="StudentController">
  <apex:form id="test" >
<apex:pageMessages/>
      <apex:pageBlock title="Choose the Object To Create Records:" >   
       <center>
          <apex:selectList value="{!source}" size="1" required="true" >
              <apex:selectOptions value="{!sourceValue}" />
              <apex:actionSupport event="onchange" action="{!objectDisplay}" reRender="test"/>
          </apex:selectList> 
       </center>   
      </apex:pageBlock>
      <apex:pageBlock rendered="{!flag}">   
          <apex:pageBlockSection title="Create Student Details" columns="1" >
           
            <apex:inputField value="{!stu1.Salutation__c}" required="true"/>
            <apex:inputField value="{!stu1.Name}" required="true"/>
            <apex:inputField value="{!stu1.Last_Name__c}" required="true"/>
            <apex:inputField value="{!stu1.Gender__c}"  required="true"/>
            <apex:inputField value="{!stu1.DOB__c}"  required="true"/>
            <apex:inputField value="{!stu1.Class__c}"  required="true"/>
            <apex:inputField value="{!stu1.Division__c}" required="true"/>
              
          </apex:pageBlockSection>         
     </apex:pageBlock>
       <apex:pageBlock rendered="{!flag1}">        
          <apex:pageBlockSection title="Create Teacher Details" columns="2" >
          
            <apex:inputField value="{!tch1.Salutation__c}" required="true" />
            <apex:inputField value="{!tch1.Name}" required="true"/>
            <apex:inputField value="{!tch1.Last_Name__c}"  required="true"/>
            <apex:inputField value="{!tch1.Gender__c}" required="true"/>
            <apex:inputField value="{!tch1.DOB__c}" required="true"/>
            <apex:inputField value="{!tch1.Class__c}"  required="true"/>
            <apex:inputField value="{!tch1.Division__c}" required="true" />

          </apex:pageBlockSection>
         
      </apex:pageBlock>
      <apex:pageBlock rendered="{!flag2}">
        <apex:pageBlockSection>
            <apex:commandButton value="Save" action="{!SaveRecord}" />
            <apex:commandButton value="Clear" action="{!clearFunction}" />
        </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

Class:--

public with sharing class StudentController {
    public string source {get;set;}
    public List<selectOption> sourceValue {get;set;}
    public boolean flag {get;set;}
    public boolean flag1 {get;set;}
    public boolean flag2 {get;set;}
    public Students__c stu1{get;set;}
    public Teacher__c tch1{get;set;}
    
    
    public StudentController()
    {
        flag = false;
        flag1 = false;
        flag2 = false;
        stu1 = new Students__c();
        tch1 = new Teacher__c();
        sourceValue = new List<selectOption>();
        sourceValue.add(new selectOption('','--select--'));
        sourceValue.add(new selectOption('Students','Students'));
        sourceValue.add(new selectOption('Teacher','Teacher'));
    }
    
    public void objectDisplay()
    { 
         If(source == 'Students'){
            flag = true;
            flag2= true;
            flag1 = false;
        }
        else if(source == 'Teacher'){
            flag1 = true;
            flag2= true;
            flag = false;
        }
    }
    public void saveRecord() {
        if(source=='Students') {
        insert stu1;
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,' Record Created Successfully.Thank you!'));
        stu1 = new Students__c();
        }
        else {
            insert tch1;
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,' Record Created Successfully.Thank you!'));
            tch1 = new Teacher__c();
        }
    }
    public void clearFunction(){
        if(source=='Students') {
        stu1 = new Students__c();
        }
        else{
        tch1 = new Teacher__c();
        }
    }
}

When i  use required = true  in input fields it is working, but i change theUser-added image select option from student to teacher or teacher to student. I'm getting this error
 
Components:--

<aura:component controller="Staffbutton" implements="lightning:availableForFlowActions, force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
       
    <aura:attribute name="Staffbutton" type="string"/>
    <aura:attribute name="StaffdId" type="String"/>  
<lightning:button label="Success" variant="brand"
         onclick="{!c.displaymsg}"/>
    </div>
</aura:component>

Controller:-
displaymsg: function (component, event, helper) {
         var toastEvent = $A.get("e.force:showToast");
            //fire the toast event in Salesforce app and Lightning Experience
            toastEvent.setParams({
                "title": "Success!",
                "type": "success",
                "mode": 'dismissable',
                "message": "The component successfully load."+component.get('v.recordId')
            });
            toastEvent.fire();
    
    
            }})



I'm not unable display record Id with toast message.

I'm getting this one..User-added image