• Abhishek Mallik
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Hi, while doing Aura input data using forms trail (https://trailhead.salesforce.com/content/learn/modules/lex_dev_lc_basics/lex_dev_lc_basics_forms) challenge, I am getting following error:

   
The campingList JavaScript controller doesn't appear to be checking if form fields are valid.


My code is as follows:

campingList.cmp
<aura:component >
    
	<aura:attribute name="items" type="Camping_Item__c[]"/>
    <aura:attribute name="newItem" type="Camping_Item__c"
                    default="{'sobjectType' : 'Camping_Item__c',
                               'Name': '',
                               'Packed__c': false,
                               'Quantity__c' : 0,
                               'Price__c' : 0}"/>
    <ol>

        <li>Bug Spray</li>

        <li>Bear Repellant</li>

        <li>Goat Food</li>

    </ol>

  <fieldset class="slds-box slds-theme--default slds-container--small">

    <legend id="newCampItemForm" class="slds-text-heading--small 
      slds-p-vertical--medium">
      Add Camping Item
    </legend>

    <form class="slds-form--stacked">

      <lightning:input aura:id="itemform" 
                       label="Name"
                       name="itemname"
                       value="{!v.newItem.Name}"
                       required="true"
      />

      <lightning:input type="number" 
                       aura:id="itemform" 
                       label="Quantity"
                       name="quantityfield"
                       value="{!v.newItem.Quantity__c}"
                       min="1"
                       required="true"
       />

      <lightning:input type="number" 
                       aura:id="itemform" 
                       label="Price"
                       name="price"
                       value="{!v.newItem.Price__c}"
                       formatter="currency"
                       step="0.1"
      />

      <lightning:input type="checkbox" 
                       aura:id="itemform" 
                       label="Packed?"
                       name="packed"
                       checked="{!v.newItem.Packed__c}"
      />

      <lightning:button label="Create Camping Item"
                        variant="brand"
                        onclick="{!c.clickCreateItem}"
      />

    </form>

  </fieldset>
   <div class ="slds-card slds-p-top--meduim">
      <header class ="slds-card__header">
         <h3 class = "slds-text-heading--small">Items</h3>
       </header>

       <section class ="slds-card__body">
          <div id="list" class = "row">
            	<aura:iteration items="{!v.items}" var="campItem">
                    <c:campingListItem item="{!campItem}"/>
                </aura:iteration>
           </div>
        </section>

    </div>

</aura:component>

campingListItem.cmp
 
<aura:component >
    <aura:attribute name="item" type="Camping_Item__c" required="true"/>        
    
    <p>Name: {!v.item.name}</p>
    <p>Price: <lightning:formattednumber value="{!v.item.Price__c}" 
                                         style="currency" 
                                         currencyCode="USD" />    </p>
    <p>Quantity:<lightning:formattednumber value="{!v.item.Quantity__c}" />
    </p>
    <p>
       <lightning:button label="Packed!" 
                           title="Packed"
                           value="{! v.item.Packed__c }"/>

    </p>
</aura:component>


and  campingListController.js
 
({
    clickCreateItem: function(component, event, helper) {

        // Simplistic error checking
        var validItem = true;

        // Name must not be blank
        var nameField = component.find("itemname");
        var itemname = nameField.get("v.value");
        if ($A.util.isEmpty(itemname)){
            validItem = false;
            nameField.set("v.errors", [{message:"Item name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
        
        // Quantity must not be blank
        var quantityField = component.find("quantity");
        var quantity = quantityField.get("v.value");
        if ($A.util.isEmpty(quantity)){
            validItem = false;
            quantityField.set("v.errors", [{message:"Quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }

        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price)){
            validItem = false;
            priceField.set("v.errors", [{message:"Price can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }


        if(validItem){            
            var newItem = JSON.parse(JSON.stringify(component.get("v.newItem")));
 
            console.log("Items before 'create': " + JSON.stringify(theItems));
		    theExpenses.push(newItem);
		    component.set("v.expenses", theItems);
		    console.log("Items after 'create': " + JSON.stringify(theItems));
            theItems.push(newItem);
            component.set("v.items", theItems);
        
        }
    }
})


In the above code though I am validating the inputs, getting no idea why still I am getting this error.
I have done the steps as mentioned in other posts as well:
 
1. Enable communities.
2. Delete the Product field from the Case object.
3. Update E_Bikes.site-meta.xml
4. Update E-Bikes Profile.profile



Now while executing the below command:
 
sfdx force:source:deploy -p force-app/main/default -u ebikesDE



I am getting below error:
PROJECT PATH ERROR ──────────────────────────────────────────────────────────────────────── ────────────────────────────────────────────────────────────────────────── force-app/main/default/flexipages/Order_Record_Page.flexipage-meta.xml You can't change a Lightning page's associated object. force-app/main/default/flexipages/Product_Record_Page.flexipage-meta.xml You can't change a Lightning page's associated object. force-app/main/default/objects/Order__c/Order__c.object-meta.xml 0M02v000000vrBO does not exist or is not a valid override for action View. force-app/main/default/objects/Product__c/Product__c.object-meta.xml 0M02v000000vrBV does not exist or is not a valid override for action View. ERROR running force:source:deploy: Deploy failed.

 
Hi,

I am trying to solve a  trail challeng on Visualforce standard list controller (Visualforce standard list controller trail (https://trailhead.salesforce.com/content/learn/modules/visualforce_fundamentals/visualforce_standard_list_controllers)). I have written the following code for the same:
 
<apex:page standardController="Account" recordSetVar="accounts"> 
<apex:pageBlock> 
<apex:repeat value="{! accounts }" var="a"> 
 <li><apex:outputLink value="{! a.id}"></apex:outputLink> </li> 
</apex:repeat> 
</apex:pageBlock> 
</apex:page>


Here while checking, I am getting following error:
 
The page does not bind to the record ID value (in order to link to the record detail page)
Hi, while doing Aura input data using forms trail (https://trailhead.salesforce.com/content/learn/modules/lex_dev_lc_basics/lex_dev_lc_basics_forms) challenge, I am getting following error:

   
The campingList JavaScript controller doesn't appear to be checking if form fields are valid.


My code is as follows:

campingList.cmp
<aura:component >
    
	<aura:attribute name="items" type="Camping_Item__c[]"/>
    <aura:attribute name="newItem" type="Camping_Item__c"
                    default="{'sobjectType' : 'Camping_Item__c',
                               'Name': '',
                               'Packed__c': false,
                               'Quantity__c' : 0,
                               'Price__c' : 0}"/>
    <ol>

        <li>Bug Spray</li>

        <li>Bear Repellant</li>

        <li>Goat Food</li>

    </ol>

  <fieldset class="slds-box slds-theme--default slds-container--small">

    <legend id="newCampItemForm" class="slds-text-heading--small 
      slds-p-vertical--medium">
      Add Camping Item
    </legend>

    <form class="slds-form--stacked">

      <lightning:input aura:id="itemform" 
                       label="Name"
                       name="itemname"
                       value="{!v.newItem.Name}"
                       required="true"
      />

      <lightning:input type="number" 
                       aura:id="itemform" 
                       label="Quantity"
                       name="quantityfield"
                       value="{!v.newItem.Quantity__c}"
                       min="1"
                       required="true"
       />

      <lightning:input type="number" 
                       aura:id="itemform" 
                       label="Price"
                       name="price"
                       value="{!v.newItem.Price__c}"
                       formatter="currency"
                       step="0.1"
      />

      <lightning:input type="checkbox" 
                       aura:id="itemform" 
                       label="Packed?"
                       name="packed"
                       checked="{!v.newItem.Packed__c}"
      />

      <lightning:button label="Create Camping Item"
                        variant="brand"
                        onclick="{!c.clickCreateItem}"
      />

    </form>

  </fieldset>
   <div class ="slds-card slds-p-top--meduim">
      <header class ="slds-card__header">
         <h3 class = "slds-text-heading--small">Items</h3>
       </header>

       <section class ="slds-card__body">
          <div id="list" class = "row">
            	<aura:iteration items="{!v.items}" var="campItem">
                    <c:campingListItem item="{!campItem}"/>
                </aura:iteration>
           </div>
        </section>

    </div>

</aura:component>

campingListItem.cmp
 
<aura:component >
    <aura:attribute name="item" type="Camping_Item__c" required="true"/>        
    
    <p>Name: {!v.item.name}</p>
    <p>Price: <lightning:formattednumber value="{!v.item.Price__c}" 
                                         style="currency" 
                                         currencyCode="USD" />    </p>
    <p>Quantity:<lightning:formattednumber value="{!v.item.Quantity__c}" />
    </p>
    <p>
       <lightning:button label="Packed!" 
                           title="Packed"
                           value="{! v.item.Packed__c }"/>

    </p>
</aura:component>


and  campingListController.js
 
({
    clickCreateItem: function(component, event, helper) {

        // Simplistic error checking
        var validItem = true;

        // Name must not be blank
        var nameField = component.find("itemname");
        var itemname = nameField.get("v.value");
        if ($A.util.isEmpty(itemname)){
            validItem = false;
            nameField.set("v.errors", [{message:"Item name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
        
        // Quantity must not be blank
        var quantityField = component.find("quantity");
        var quantity = quantityField.get("v.value");
        if ($A.util.isEmpty(quantity)){
            validItem = false;
            quantityField.set("v.errors", [{message:"Quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }

        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price)){
            validItem = false;
            priceField.set("v.errors", [{message:"Price can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }


        if(validItem){            
            var newItem = JSON.parse(JSON.stringify(component.get("v.newItem")));
 
            console.log("Items before 'create': " + JSON.stringify(theItems));
		    theExpenses.push(newItem);
		    component.set("v.expenses", theItems);
		    console.log("Items after 'create': " + JSON.stringify(theItems));
            theItems.push(newItem);
            component.set("v.items", theItems);
        
        }
    }
})


In the above code though I am validating the inputs, getting no idea why still I am getting this error.