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
Bob 11Bob 11 

Salesforce lightning component required field message on every field

I have a lightning component that has required fields. my issue is i want the require field message to be displayed on every field if it is missing that information and not at the top of the page. I was wondering if anyone could help me with updating the code below to accomplish this update.

Lightning Component
<aura:component description="ContactQuestions" controller="ContactQuestionsController" implements="forceCommunity:availableForAllPageTypes,lightning:isUrlAddressable" access="global">
    <aura:attribute name="toScheduling" type="Boolean" default="false"/>
    <aura:attribute name="displayFlowModal" type="Boolean" default="false"/>
    <aura:attribute name="showAssist" type="Boolean" default="false"/>
    <aura:attribute name="showError" type="Boolean" default="false"/>
    <aura:attribute name="errorMessage" type="String"/>
    <aura:attribute name="firstname" type="string"/>
    <aura:attribute name="lastname" type="string"/>
    <aura:attribute name="email" type="string"/>
    <aura:attribute name="gasUtilityNumber" type="string"/>
    <aura:attribute name="electricUtilityNumber" type="string"/>
    <aura:attribute name="phoneNum" type="string"/>
    <aura:attribute name="serviceZip" type="string"/>
    <aura:attribute name="opLang" type="List"/>
    <aura:attribute name="opHeatFuel" type="List"/>
    <aura:attribute name="opCondo" type="List"/>
    <aura:attribute name="opOwnRent" type="List"/>
    <aura:attribute name="opHear" type="List"/>
    <aura:attribute name="opBuildingType" type="List"/>
    <aura:attribute name="opGasUtilHolder" type="List"/>
    <aura:attribute name="opElectricUtilHolder" type="List"/>
    <aura:attribute name="opHeatWith" type="List"/>
    <aura:attribute name="opSquareFeet" type="List"/>
    <aura:attribute name="opHowMany" type="List"/>
    <aura:attribute name="opWhyContactUs" type="List"/>
    <aura:attribute name="opMakeImprove" type="List"/>
    <aura:attribute name="opHowManyUnits" type="List"/>
    <aura:attribute name="opHomeStyle" type="List"/>
    <aura:attribute name="opPrimaryFuel" type="List"/>
    <aura:attribute name="opSecondaryFuel" type="List"/>
    <aura:attribute name="opLive" type="List" default="[
    {'label': 'Yes', 'value': 'yes'},
    {'label': 'No', 'value': 'no'}]"/>
    <aura:attribute name="recordId" type="String"/>

    <!-- Contact Attributes -->
    <aura:attribute name="ContactInformation" type="Object"/>
    <aura:attribute name="preferredLanguage" type="String"/>
    <aura:attribute name="streetAddress" type="String"/>
    <aura:attribute name="zip" type="String"/>
    <aura:attribute name="city" type="String"/>
    <aura:attribute name="state" type="String"/>
    <aura:attribute name="mobile" type="String"/>
    <aura:attribute name="alternatePhone" type="String"/>
<!--    <aura:attribute name="heatFuel" type="String"/>-->
    <aura:attribute name="condoAssoc" type="String"/>
    <aura:attribute name="makeImprovements" type="String"/>
    <aura:attribute name="ownOrRent" type="String"/>
    <aura:attribute name="liveThere" type="String"/>
    <aura:attribute name="howHear" type="String"/>
<!--    <aura:attribute name="promoCode" type="String"/>-->
    <aura:attribute name="whyContactUs" type="String"/>
    <aura:attribute name="gasUtilHolder" type="String"/>
    <aura:attribute name="electricUtilHolder" type="String"/>
    <aura:attribute name="abandonedForm" type="Boolean"/>
    <aura:attribute name="externalLead" type="Boolean"/>

    <!-- Account Attributes -->
    <aura:attribute name="howManyUnits" type="Integer"/>
    <aura:attribute name="yearBuilt" type="String"/>
    <aura:attribute name="sqFeet" type="Integer"/>
    <aura:attribute name="primaryFuel" type="String"/>
    <aura:attribute name="secondaryFuel" type="String"/>
    <aura:attribute name="buildingType" type="String"/>
    <aura:attribute name="homeStyle" type="String"/>
    <aura:attribute name="primaryFuelPercent" type="Integer" default="50"/>
    <aura:attribute name="secondaryFuelPercent" type="Integer" default="50"/>
    <aura:attribute name="landlordName" type="String"/>
    <aura:attribute name="landlordEmail" type="String"/>
    <aura:attribute name="landlordPhone" type="String"/>
    <aura:attribute name="associationName" type="String"/>
    <aura:attribute name="associationEmail" type="String"/>
    <aura:attribute name="associationPhone" type="String"/>
    <aura:attribute name="optOut" type="Boolean" default="false"/>
    <aura:attribute name="gasHolderFirstName" type="String"/>
    <aura:attribute name="gasHolderLastName" type="String"/>
    <aura:attribute name="electricHolderFirstName" type="String"/>
    <aura:attribute name="electricHolderLastName" type="String"/>

    <!-- Accordion Attributes -->
    <aura:attribute name="section" type="String"/>

    <lightning:navigation aura:id="navService"/>

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <aura:if isTrue="{!!v.toScheduling}">
        <lightning:layout horizontalAlign="spread">
            <lightning:layoutItem size = "2"><lightning:input type="text" label="First Name" value="{!v.ContactInformation.FirstName}" disabled="true"/></lightning:layoutItem>
            <lightning:layoutItem size = "2"><lightning:input type="text" label ="Last Name" value="{!v.ContactInformation.LastName}" disabled="true"/></lightning:layoutItem>
            <lightning:layoutItem size = "2"><lightning:input type="text" label = "Email" value="{!v.ContactInformation.Email}" disabled="true"/></lightning:layoutItem>
            <lightning:layoutItem size = "2"><lightning:input type="text" label = "Phone" value="{!v.ContactInformation.Phone}" disabled="true"/></lightning:layoutItem>
            <lightning:layoutItem size = "2"><lightning:input type="text" label = "Zip Code" value="{!v.ContactInformation.MailingPostalCode}" disabled="true"/></lightning:layoutItem>
        </lightning:layout>

        <lightning:accordion aura:id="accordion" allowMultipleSectionsOpen="true" activeSectionName="{!v.section}" onsectiontoggle="{!c.handleSectionToggle}">
            <lightning:layout class="slds-align_absolute-center">
                <lightning:layoutItem size = "6" padding="around-small">
                    <aura:if isTrue="{!v.showError}">
                        <div id="error" class="errormessage">
                            <lightning:input value="{!v.errorMessage}" readonly="true"/>
                        </div>
                    </aura:if>
                    
                    <br/>
                    <lightning:accordionSection name="reason" label="What brought you here today">
                        <lightning:combobox options="{!v.opHear}" value="{!v.howHear}" aura:id="howHear" class="widthFix" required="true" label="How did you hear about us?"/>
                        <lightning:combobox options="{!v.opWhyContactUs}" value="{!v.whyContactUs}" aura:id="whyContactUs" class="widthFix" required="true" label="What is the primary reason you contacted us?"/>
                    </lightning:accordionSection>
                    <lightning:accordionSection name="home" label="Tell us a bit more about your home">
                        <lightning:combobox options="{!v.opPrimaryFuel}" value="{!v.primaryFuel}" aura:id="primFuel" class="widthFix" required="true" label="What is your primary heat fuel?"/>
                        <lightning:input type="text" value="{!v.streetAddress}" maxlength="100" aura:id="streetAddress" class="input" required="true" label="Street Address"/>
                        <lightning:input type="text" value="{!v.zip}" maxlength="10" aura:id="zip" class="input" required="true" label="Zip"/>
                        <lightning:input type="text" value="{!v.city}" maxlength="25" aura:id="city" class="input" required="true" label="City"/>
                        <lightning:input type="text" value="{!v.state}" maxlength="10" aura:id="state" class="input" required="true" label="State"/>
                        <lightning:input type="text" value="{!v.mobile}" maxlength="12" aura:id="mobile" class="input" required="false" label="Mobile Phone"/>
                        <lightning:input type="text" value="{!v.alternatePhone}" maxlength="12" aura:id="alternatePhone" class="input" label="Alternate Phone"/>
                        <lightning:combobox options="{!v.opOwnRent}" value="{!v.ownOrRent}" aura:id="ownOrRent" class="widthFix" label="Are you the owner, tenant or landlord?"/>
                        <aura:if isTrue="{!v.ownOrRent == 'Tenant'}">
                            <lightning:input type="text" value="{!v.landlordName}" maxlength="100" aura:id="landlordName" class="input" label="Landlord Name"/>
                            <lightning:input type="email" value="{!v.landlordEmail}" maxlength="255" aura:id="landlordEmail" class="input" label="Landlord Email"/>
                            <lightning:input type="tel" value="{!v.landlordPhone}" maxlength="40" aura:id="landlordPhone" class="input" label="Landlord Phone"/>
                        </aura:if>
                        <aura:if isTrue="{!or(v.ownOrRent == 'Owner', v.ownOrRent == 'Landlord')}">
                            <lightning:combobox options="{!v.opLive}" value="{!v.liveThere}" aura:id="liveThere" class="widthFix" label="Do you reside in this dwelling?"/>
                        </aura:if>
<!--                        <aura:if isTrue="{!v.ownOrRent == 'Owner'}">-->
<!--                            <lightning:combobox options="{!v.opLive}" value="{!v.liveThere}" aura:id="liveThere" class="widthFix" label="Do you own or rent?"/>-->
<!--                        </aura:if>-->
                        <lightning:combobox options="{!v.opBuildingType}" value="{!v.buildingType}" aura:id="homeStyle" class="widthFix" label="What is your building type?"/>
                      <!--  <lightning:combobox options="{!v.opHowManyUnits}" value="{!v.howManyUnits}" aura:id="units" class="widthFix" label="How many units?"/> -->
                        <lightning:combobox options="{!v.opHomeStyle}" value="{!v.homeStyle}" aura:id="homeStyle" class="widthFix" label="What is the home style?"/>
                        <lightning:input aura:id="yearBuilt" class="input" value="{!v.yearBuilt}" minlength="4" maxlength="4" label="What year was your home built?"/>
                        <lightning:combobox options="{!v.opSquareFeet}" value="{!v.sqFeet}" aura:id="squareFeet" class="widthFix" label="The approximate Square footage of living space, (not including garage, basements, attic)"/>
                        <lightning:combobox options="{!v.opCondo}" value="{!v.condoAssoc}" aura:id="condoAss" class="widthFix" label="Do you have a Condo Association?"/>
                        <lightning:input type="checkbox" value="{!v.optOut}" onchange="{!c.optOutOfEmails}" aura:id="optOut" class="input" label="Opt Out of Promotional Emails"/>
                      <!--  <aura:if isTrue="{!v.condoAssoc == 'Yes'}">
                            <lightning:combobox options="{!v.opMakeImprove}" value="{!v.makeImprovements}" aura:id="makeImprovs" class="widthFix" label="Can you make improvements to your building without association approval?"/>
                            <aura:if isTrue="{!v.makeImprovements == 'No'}">
                                <lightning:input type="text" value="{!v.associationName}" maxlength="100" aura:id="associationName" class="input" label="Association Name"/>
                                <lightning:input type="email" value="{!v.associationEmail}" maxlength="255" aura:id="associationEmail" class="input" label="Association Email"/>
                                <lightning:input type="tel" value="{!v.associationPhone}" maxlength="40" aura:id="associationPhone" class="input" label="Association Phone"/>
                            </aura:if>
                        </aura:if> -->
                    </lightning:accordionSection>
                    <lightning:accordionSection name="account" label="Account information">
                        <aura:if isTrue="{!v.primaryFuel == 'Natural Gas'}">
                        <lightning:input type="text" value="{!v.gasUtilityNumber}" maxlength="100" aura:id="gasUtilNumber" class="input" required="false" label="Gas Utility Number"/>
                        <lightning:combobox options="{!v.opGasUtilHolder}" value="{!v.gasUtilHolder}" aura:id="gasUtilHolder" class="widthFix" label="Are you listed as the Gas Account holder?"/>
                        <aura:if isTrue="{!v.gasUtilHolder == 'No'}">
                            <lightning:input type="text" value="{!v.gasHolderFirstName}" maxlength="100" aura:id="gasHolderFirstName" class="input" label="Gas Account Holder First Name"/>
                            <lightning:input type="text" value="{!v.gasHolderLastName}" maxlength="100" aura:id="gasHolderLastName" class="input" label="Gas Account Holder Last Name"/>
                        </aura:if>
                        </aura:if>
                        <lightning:input type="text" value="{!v.electricUtilityNumber}" maxlength="100" aura:id="electricUtilNumber" class="input" required="false" label="Electric Utility Number"/>
                        <lightning:combobox options="{!v.opElectricUtilHolder}" value="{!v.electricUtilHolder}" aura:id="electricUtilHolder" class="widthFix" label="Are you listed as the Electric Account holder?"/>
                        <aura:if isTrue="{!v.electricUtilHolder == 'No'}">
                            <lightning:input type="text" value="{!v.electricHolderFirstName}" maxlength="100" aura:id="electricHolderFirstName" class="input" label="Electric Account Holder First Name"/>
                            <lightning:input type="text" value="{!v.electricHolderLastName}" maxlength="100" aura:id="electricHolderLastName" class="input" label="Electric Account Holder Last Name"/>
                        </aura:if>
                    </lightning:accordionSection>
                </lightning:layoutItem>
            </lightning:layout>
        </lightning:accordion>

        <div class="slds-text-align--right">
            <lightning:button variant="brand-outline" class="slds-m-right_medium" label="Exit" name="cancel" onclick="{!c.navigateToHomePage}" aura:id="exitToHome"/>
            <lightning:button variant="brand-outline" class="slds-m-right_medium" label="Don’t Have Account Information" name="cancel" onclick="{!c.navigateToSchedulingSupport}" aura:id="schedulingSupport"/>
            <lightning:buttonGroup>
                <lightning:button variant="brand" label="Book Appointment" name="schedule" onclick="{!c.completeRegistration}" aura:id="submitreg"/>
            </lightning:buttonGroup>
        </div>

    </aura:if>
    <aura:if isTrue="{!v.toScheduling}">
       <c:FSL_AppointmentBooking></c:FSL_AppointmentBooking>
    </aura:if>
</aura:component>


 
Bob 11Bob 11
This is the helper
({
    getContactRecord : function(component,event){
        console.log('in get record method');
        const queryString = window.location.search;
        console.log(queryString);
        const urlParams = new URLSearchParams(queryString);
        let recordId = urlParams.get('recordId');
        component.set("v.recordId",recordId);
        console.log('record id: '+component.get("v.recordId"));

        var action = component.get("c.getCurrentContact");
        action.setParams({recId:recordId});
        action.setCallback(this, function(result){
            let state = result.getState();
            if(state === 'SUCCESS') {
                const returnVal = result.getReturnValue();
                console.log('Contact: ' + JSON.stringify(returnVal));
                component.set("v.ContactInformation", returnVal);

                if(returnVal.Account.BillingCity !== null & returnVal.Account.BillingCity !== '' && returnVal.Account.BillingCity !== undefined) {
                    component.set("v.city", returnVal.Account.BillingCity);

                } else if(returnVal.MailingCity !== null & returnVal.MailingCity !== '' && returnVal.MailingCity !== undefined){
                    component.set("v.city", returnVal.MailingCity);
                }
                if(returnVal.Account.BillingState !== null & returnVal.Account.BillingState !== '' && returnVal.Account.BillingState !== undefined) {
                    component.set("v.state", returnVal.Account.BillingState);
                } else if(returnVal.MailingState !== null & returnVal.MailingState !== '' && returnVal.MailingState !== undefined) {
                    component.set("v.state", returnVal.MailingState);
                }
                                if(returnVal.Account.BillingStreet !== null & returnVal.Account.BillingStreet !== '' && returnVal.Account.BillingStreet !== undefined) {
                    component.set("v.streetAddress", returnVal.Account.BillingStreet);
                } else if(returnVal.MailingStreet !== null & returnVal.MailingStreet !== '' && returnVal.MailingStreet !== undefined) {
                    component.set("v.streetAddress", returnVal.MailingStreet);
                }
                                if(returnVal.Account.BillingPostalCode !== null & returnVal.Account.BillingPostalCode !== '' && returnVal.Account.BillingPostalCode !== undefined) {
                    component.set("v.zip", returnVal.Account.BillingState);
                } else if(returnVal.MailingPostalCode !== null & returnVal.MailingPostalCode !== '' && returnVal.MailingPostalCode !== undefined) {
                    component.set("v.zip", returnVal.MailingPostalCode);
                }
                if(returnVal.Account.Utility_Service_Fuel_Type__c === 'EL') {
                    component.set("v.electricUtilityNumber", returnVal.Account.Utility_Number__c);
                }
            }else {
                console.log('There was an error in the callback',result.getError());
            }
        });
        $A.enqueueAction(action);
    },

    updateCustomerRecord : function(cmp){
        console.log('made it to helper to update record');

        let externalLead = false;
        if((cmp.get('v.gasUtilityNumber') === '' || cmp.get('v.gasUtilityNumber') === null || cmp.get('v.gasUtilityNumber') === undefined) &&
            (cmp.get('v.gasUtilHolder') === '' || cmp.get('v.gasUtilHolder') === null || cmp.get('v.gasUtilHolder') === undefined) &&
            (cmp.get('v.gasHolderFirstName') === '' || cmp.get('v.gasHolderFirstName') === null || cmp.get('v.gasHolderFirstName') === undefined) &&
            (cmp.get('v.gasHolderLastName') === '' || cmp.get('v.gasHolderLastName') === null || cmp.get('v.gasHolderLastName') === undefined) &&
            (cmp.get('v.electricUtilityNumber') === '' || cmp.get('v.electricUtilityNumber') === null || cmp.get('v.electricUtilityNumber') === undefined) &&
            (cmp.get('v.electricUtilHolder') === '' || cmp.get('v.electricUtilHolder') === null || cmp.get('v.electricUtilHolder') === undefined) &&
            (cmp.get('v.electricHolderFirstName') === '' || cmp.get('v.electricHolderFirstName') === null || cmp.get('v.electricHolderFirstName') === undefined) &&
            (cmp.get('v.electricHolderLastName') === '' || cmp.get('v.electricHolderLastName') === null || cmp.get('v.electricHolderLastName') === undefined)) {
            externalLead = true;
        }
        console.log('@@@@ externalLead: ' + externalLead);
        //Contact fields
        // const isMultiHeat = cmp.get('v.heatFuel') === 'I heat more than one fuel';
        const contactInfo = {
            contact: cmp.get("v.ContactInformation"),
            preferredLang: cmp.get("v.preferredLanguage"),
            howHear: cmp.get('v.howHear'),
            whyContactUs: cmp.get("v.whyContactUs"),
            streetAddress: cmp.get("v.streetAddress"),
            zip: cmp.get("v.zip"),
            city: cmp.get("v.city"),
            state: cmp.get("v.state"),
            mobile: cmp.get("v.mobile"),
            alternatePhone: cmp.get("v.alternatePhone"),
            optOut: cmp.get("v.optOut"),
            ownOrRent: cmp.get("v.ownOrRent"),
            liveThere: cmp.get("v.liveThere"),
            condoAssoc: cmp.get("v.condoAssoc"),
            makeImprovements: cmp.get("v.makeImprovements"),
            gasUtilityNumber: cmp.get('v.gasUtilityNumber'),
            gasUtilHolder: cmp.get('v.gasUtilHolder'),
            gasHolderFirstName: cmp.get('v.gasHolderFirstName'),
            gasHolderLastName: cmp.get('v.gasHolderLastName'),
            electricUtilityNumber: cmp.get('v.electricUtilityNumber'),
            electricUtilHolder: cmp.get('v.electricUtilHolder'),
            electricHolderFirstName: cmp.get('v.electricHolderFirstName'),
            electricHolderLastName: cmp.get('v.electricHolderLastName'),
            externalLead: externalLead
            // heatFuel: cmp.get('v.heatFuel'),
            // promoCode: cmp.get('v.promoCode')
        }
        //Account & AccountContactRelation fields - There's an issues somewhere in the accountInfo object
        const accountInfo = {
            accountId: contactInfo.contact.AccountId,
            // primaryFuel: (isMultiHeat ? cmp.get('v.primaryFuel') : null),
            primaryFuel: cmp.get('v.primaryFuel'),
            landlordName: cmp.get('v.landlordName'),
            landlordEmail: cmp.get('v.landlordEmail'),
            landlordPhone: cmp.get('v.landlordPhone'),
            buildingType: cmp.get('v.buildingType'),
          //  howManyUnits: cmp.get('v.howManyUnits'),
            homeStyle: cmp.get('v.homeStyle'),
            yearBuilt: cmp.get('v.yearBuilt'),
            sqFeet: cmp.get('v.sqFeet'),
            associationName: cmp.get('v.associationName'),
            associationEmail: cmp.get('v.associationEmail'),
            associationPhone: cmp.get('v.associationPhone'),
            // secondaryFuel: (isMultiHeat ? cmp.get('v.secondaryFuel') : null),
            // primaryFuelPercent: (isMultiHeat ? parseInt(cmp.get('v.primaryFuelPercent'), 10) : null),
            // secondaryFuelPercent: (isMultiHeat ? parseInt(cmp.get('v.secondaryFuelPercent'), 10) : null),
        }
        console.log('contactInfo', contactInfo);
        console.log('accountInfo', accountInfo);

        if((contactInfo.preferredLang === '' || contactInfo.preferredLang === null || contactInfo.preferredLang === undefined) ||
            (contactInfo.howHear === '' || contactInfo.howHear === null || contactInfo.howHear === undefined) ||
            (contactInfo.whyContactUs === '' || contactInfo.whyContactUs === null || contactInfo.whyContactUs === undefined) ||
            (accountInfo.primaryFuel === '' || accountInfo.primaryFuel === null || accountInfo.primaryFuel === undefined) ||
            (contactInfo.streetAddress === '' || contactInfo.streetAddress === null || contactInfo.streetAddress === undefined) ||
            (contactInfo.zip === '' || contactInfo.zip === null || contactInfo.zip === undefined) ||
            (contactInfo.city === '' || contactInfo.city === null || contactInfo.city === undefined) ||
            (contactInfo.state === '' || contactInfo.state === null || contactInfo.state === undefined)) {
            console.log('@@@@ Please fill in the required fields.');
            cmp.set("v.showError",true);
            cmp.set("v.errorMessage",'Please fill in the required fields.');
        } else {
            console.log('@@@@ Book Appt.');
            var action = cmp.get('c.updateCustomer');
            action.setParams({
                contactInfo: contactInfo,
                accountInfo: accountInfo
            });
            action.setCallback(this, function(a){
                console.log('Contact Returned');
                console.log(JSON.stringify(a.getReturnValue())); //empty value?
                var Contact = a.getReturnValue();
                if (Contact == null) {
                    cmp.set("v.showError",true);
                    cmp.set("v.errorMessage",'This contact was not returned');
                }else {
                    console.log('AAAAAAAAAAA');
                    console.log('a.getReturnValue(): ' + JSON.stringify(a.getReturnValue()));
                    console.log('howManyUnits: ' + cmp.get('v.howManyUnits'));
                    console.log('buildingType: ' + cmp.get('v.buildingType'));
                    console.log('sqFeet: ' + cmp.get('v.sqFeet'));
                    console.log('condoAssoc: ' + cmp.get('v.condoAssoc'));
                    console.log('gasUtilityNumber: ' + cmp.get('v.gasUtilityNumber'));
                    console.log('electricUtilityNumber: ' + cmp.get('v.electricUtilityNumber'));
                    console.log('Contact.Account.Eligible_Testing__c : ' + Contact.Account.Eligible_Testing__c);
                    cmp.set('v.ContactInformation', a.getReturnValue());
                    console.log('AAAAAAAAAAAAA');
                    if (cmp.get('v.buildingType') !== 'Single-Family Home' || cmp.get('v.sqFeet') === '3000-3500 sq ft' || cmp.get('v.sqFeet') === '3500-6000 sq ft' || cmp.get('v.sqFeet') === '6000+ sq ft' || cmp.get('v.condoAssoc') === 'Yes' || (cmp.get('v.gasUtilityNumber') === '' && cmp.get('v.electricUtilityNumber') === '') || Contact.Account.Eligible_Testing__c === false){
                        console.log('BBBBBBBBBBB');
                        cmp.find('navService').navigate({
                            type: 'standard__namedPage',
                            attributes: {
                                name: 'Contact_Support'
                            }
                        });
                    } else {
                        console.log('CCCCCCCCCCC');
                        cmp.find('navService').navigate({
                            type: 'standard__namedPage',
                            attributes: {
                                name: 'Schedule__c'
                            }
                        });
                    }}
            });
            $A.enqueueAction(action);
        }
    },

    navigateHome : function(cmp) {
        var action = cmp.get('c.formAbandoned');
        action.setParams({
            recId: cmp.get("v.recordId")
        });
        action.setCallback(this, function(a){
            console.log('Contact Abandoned');
        });
        $A.enqueueAction(action);

        cmp.find('navService').navigate({
            type: 'standard__namedPage',
            attributes: {
                name: 'Home'
            }
        });
    },

    navigateSupport : function(cmp) {
        cmp.find('navService').navigate({
            type: 'standard__namedPage',
            attributes: {
                name: 'Scheduling_Support__c'
            }
        });
    },

    getPrefLang : function (component,event){
        console.log('in get Pref Lang method.');
        var ObjectName = "Contact";
        var FieldName = "Preferred_Language__c";
        var action = component.get('c.getPicklistValues');
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opLang",optionList);
            component.set( "v.preferredLanguage", "English" ); //default English
        });
        $A.enqueueAction(action);
    },
    getHeatFuel : function (component,event){
        var ObjectName = "Contact";
        var FieldName = "How_do_you_heat_your_home__c";
        var action = component.get('c.getPicklistValues');
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            console.log('opHeatFuel opList: ', optionList);
            component.set("v.opHeatFuel",optionList);
        });
        $A.enqueueAction(action);
    },
    getCondoAssoc : function (component,event){
        var ObjectName = "Contact";
        var FieldName = "Part_of_Condo_Association__c";
        var action = component.get('c.getPicklistValues');
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opCondo",optionList);
        });
        $A.enqueueAction(action);
    },
    getOwnRent : function (component,event){
        var ObjectName = "Contact";
        var FieldName = "Are_you_the_owner_tenant_or_landlord__c";
        var action = component.get('c.getPicklistValues');
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opOwnRent",optionList);
        });
        $A.enqueueAction(action);
    },
    getLiveThere : function (component,event){
        var ObjectName = "Contact";
        var FieldName = "Do_you_own_or_rent__c";
        var action = component.get('c.getPicklistValues');
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opLive",optionList);
        });
        $A.enqueueAction(action);
    },
    getHearAbout : function (component,event){
        var ObjectName = "Contact";
        var FieldName = "How_did_you_hear_about_us__c";
        var action = component.get('c.getPicklistValues');
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opHear",optionList);
        });
        $A.enqueueAction(action);
    },
    getWhyContactUs : function(component, event) {
        var ObjectName = "Contact";
        var FieldName = "Why_did_you_contact_us__c";
        var action = component.get("c.getPicklistValues");
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
             var optionList = result.getReturnValue();
             console.log('What is the primary reason you contacted us options: ', optionList);
             component.set("v.opWhyContactUs", optionList);
        });
        $A.enqueueAction(action);
    },
    getMakeImprovements : function(component, event) {
        var ObjectName = "Contact";
        var FieldName = "Make_improvements_without_approval__c";
        var action = component.get("c.getPicklistValues");
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opMakeImprove", optionList);
        });
        $A.enqueueAction(action);
    },
    getSquareFeet : function(component, event) {
        var ObjectName = "Account";
        var FieldName = "Square_Footage__c";
        var action = component.get("c.getPicklistValues");
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opSquareFeet", optionList);
        });
        $A.enqueueAction(action);
    },
    getBuidlingType : function(component, event) {
        var ObjectName = "Account";
        var FieldName = "Building_Type__c";
        var action = component.get("c.getPicklistValues");
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            console.log('@@@@ result: ' + JSON.stringify(result));
            var optionList = result.getReturnValue();
            component.set("v.opBuildingType", optionList);
        });
        $A.enqueueAction(action);
    },
    getHomeStyle : function(component, event) {
        var ObjectName = "Account";
        var FieldName = "Home_Style__c";
        var action = component.get("c.getPicklistValues");
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opHomeStyle", optionList);
        });
        $A.enqueueAction(action);
    },
    getGasUtilHolder : function(component, event) {
        var ObjectName = "Contact";
        var FieldName = "Gas_utility_account_holder__c";
        var action = component.get("c.getPicklistValues");
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opGasUtilHolder", optionList);
        });
        $A.enqueueAction(action);
    },
    getElectricUtilHolder : function(component, event) {
        var ObjectName = "Contact";
        var FieldName = "Electric_utility_account_holder__c";
        var action = component.get("c.getPicklistValues");
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opElectricUtilHolder", optionList);
        });
        $A.enqueueAction(action);
    },
    getPrimaryFuelType : function(component, event) {
        var ObjectName = "Account";
        var FieldName = "Primary_Fuel_Type__c";
        var action = component.get("c.getPicklistValues");
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opPrimaryFuel", optionList);
        });
        $A.enqueueAction(action);
    },
    getSecondaryFuelType : function(component, event) {
        var ObjectName = "Account";
        var FieldName = "Secondary_Fuel_Type__c";
        var action = component.get("c.getPicklistValues");
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opSecondaryFuel", optionList);
        });
        $A.enqueueAction(action);
    },
    getHowManyUnits : function(component, event) {
        var ObjectName = "Account";
        var FieldName = "Number_of_Units_in_Building__c";
        var action = component.get("c.getPicklistValues");
        action.setParams({objectName:ObjectName,fieldName:FieldName});
        action.setCallback(this, function(result){
            var optionList = result.getReturnValue();
            component.set("v.opHowManyUnits", optionList);
        });
        $A.enqueueAction(action);
    }

})