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
Vineet Anand 5Vineet Anand 5 

Invalid definition for null

Hi All,
For PD2 Super Badge "Aura Component Specialist Task 4" I am getting below error:
"Failed to save BoatSearchForm.cmp: Invalid definition for null:BoatSearchFormController: ApexService.getType() return null with currentNamespace: c, namespace: null, name: BoatSearchFormController: Source"

Enclosing Boat Searchform.cmp:
<aura:component controller="BoatSearchFormController" implements="force:appHostable,flexipage:availableForAllPageTypes">
    <aura:handler name="formsubmit" event="c:FormSubmit" action="{!c.onFormSubmit}" phase="capture"/>
    <aura:attribute access="private" name="boatTypeList" type="BoatType__c[]" default="[]"/>
    <aura:attribute access="private" name="boatTypeIdByNameMap" type="Map"/>
    <aura:attribute access="private" name="selectedBoatType" type="BoatType__c"/>
    <aura:attribute access="private" name="showNewButton" type="Boolean" default="false"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <!--<h2 class="slds-page-header__title">Find a Boat</h2>-->
    <form>
        <lightning:layout horizontalAlign="center" verticalAlign="end">
            <lightning:select name="select" value="{!v.selectedBoatType}">    
                <option value="">All Types</option>
                <aura:iteration items="{!v.boatTypeList}" var="boatType">
                    <option value="{!boatType.Name}">{!boatType.Name}</option>
                </aura:iteration> 
            </lightning:select>
                <lightning:button name="Search" label="Search" variant="brand" onclick="{!c.onFormSubmit}" />
            <aura:if isTrue="{!v.showNewButton}">
                <lightning:button name="New" label="New" variant="neutral" onclick="{!c.createBoat}"/>
            </aura:if>
        </lightning:layout>
    </form>    
</aura:component>

BoatsearchformController.js
({
    doInit: function(component, event, helper) {
 var createNewBoat = $A.get("e.force:createRecord");
        if (createNewBoat) {
            component.set("v.showNewButton", true);
        }else{
             component.set("v.showNewButton", false);
        }
    var action = component.get("c.getboattypes");

    // Add callback behavior for when response is received
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            debugger
            console.log("responce : " + response.getReturnValue());
            component.set("v.btypes", response.getReturnValue());
        }
        else {
            console.log("Failed with state: " + state);
        }
    });

    // Send action off to be executed
    $A.enqueueAction(action);
    },
    createBoat: function (component) 
     {
            console.log('inside controller');
            var createRecordEvent = $A.get('e.force:createRecord');
            if (createRecordEvent) 
            {
                    var typeName = component.find('typeSelect').get('v.value');
                    //var typeMap = component.get('v.searchOptionToIdMap');
                    var typeId = null;
                    if (typeName) 
                    {
                            typeId = typeName;
                    }
                    createRecordEvent.setParams({
                        'entityApiName': 'Boat__c',
                        'defaultFieldValues': {
                            'BoatType__c': typeId
                        }
                    });
                    createRecordEvent.fire();
            }
       },
    onFormSubmit:function(component, event, helper) {
        debugger
        // var myEvent = $A.get("e.c:BoatSearchEvent");
        // myEvent.setParams({"typeId": component.get("v.selectedType")});
        // myEvent.fire();
        console.log("selectType "+ component.get("v.selectedType") );
        var boatTypeId = component.get("v.selectedType");
        console.log("Search button pressed " + boatTypeId);
        var formSubmit = component.getEvent("formsubmit");
        formSubmit.setParams({"formData":
                            {"boatTypeId" : boatTypeId}
        });
        formSubmit.fire();
        },
    handleChange:function(component, event, helper) {
        var y=component.find("boatTypes").get("v.value");
        console.log("val :  "+ y);
        component.set("v.selectedType",component.find("boatTypes").get("v.value"));
    }    
})

Please suggest remedy.

Rgd's
Swati Taunk 15Swati Taunk 15
@Vineet did you find a solution for this? I am also stuck with same error.