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
anmi ch 6anmi ch 6 

Failed to save campingList.cmp: Invalid definition for null:CampingListController: ApexService.getType() return null with currentNamespace: c, namespace: null, name: CampingListController: Source

hi guys  ,
while i am saving the code i am getting this error"Failed to save campingList.cmp: Invalid definition for null:CampingListController: ApexService.getType() return null with currentNamespace: c, namespace: null, name: CampingListController: Source" I do not know where ii am doing the error and below is my code .


campinglist.cmp
    

<aura:component controller="CampingListController" >

    <aura:attribute name="items" type="Camping_Item__c[]" />
   
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
   
    <aura:attribute name="newItem" type="Camping_Item__c" default="{'sObjectType':'Camping_Item__c','Quantity__c':0,'Price__c':0}" />
      
    <br/><br/>
    <p>Name:
    <ui:inputText aura:id="name" value="{!v.newItem.Name}" Label="Name" />
    </p><br/>
    <p>Quantity:
    <ui:inputNumber aura:id="quantity" value="{!v.newItem.Quantity__c}" Label="Quantity" />
    </p><br/>
    <p>Price:
    <ui:inputCurrency aura:id="price" value="{!v.newItem.Price__c}" Label="Price" />
    </p><br/>
    <p>Packed?:
    <ui:inputCheckBox value="{!v.newItem.Packed__c}" Label="Packed" />
    </p><br />
   
    <ui:button label="Submit" press="{!c.PushItems}" />
   
    <aura:iteration items="{!v.items}" var="item">
   
    <p> <ui:outputText value="{!item.Name}" /> </p>
   
    <p> <ui:outputNumber value="{!item.Quantity__c}" /> </p>
   
    <p> <ui:outputCurrency value="{!item.Price__c}" />  </p>
   
    <p> <ui:outputCheckbox value="{!item.Packed__c}" /> </p>  
       
    </aura:iteration>
       

</aura:component>

can anyone help me .

 
Abdul KhatriAbdul Khatri
Hi anmi,

Have you created an apex class by the name CampingListController?
anmi ch 6anmi ch 6
hi 
Abdul i did not created 
Abdul KhatriAbdul Khatri
Hi anmi,

Therefore you are getting this message you have two solutions
  1. Remove the controller attribute for now until you get to that level
  2. Create that Apex Class with the following code
public with sharing class CampingListController {

    @AuraEnabled
    public static List<Camping_Item__c> getItems(){
        return [SELECT Id, Name, Price__c, Quantity__c, Packed__c, CreatedDate
               		FROM Camping_Item__c];
    }
    
	@AuraEnabled
    public static Camping_Item__c saveItem(Camping_Item__c newCampingItem){
        try{
        upsert newCampingItem;
            system.debug('success');
        return newCampingItem;
        }catch(Exception ex){
            system.debug('newCampingItem : ' + newCampingItem);
            system.debug('Exception : ' + ex.getMessage());
            return null;
        }
    }
}

 
Abdul KhatriAbdul Khatri
Hi anmi

Were my suggestions helpful?