• Orchay Naeh
  • NEWBIE
  • 70 Points
  • Member since 2017

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 12
    Replies
first of all hello : )
i working my way through the trailhead training and encountered a problem submitting this challenge.
the code itself works yet i get an error of :

Challenge Not yet complete... here's what's wrong: 
The campingList component doesn't appear to have a Quantity input field in the form using a Lightning Base component.


i guess its a default message for somthing else, any suggestion will be appreciated, i am posting my classes below,

CampingList.cmp
<aura:component controller="CampingListController">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}"/>
 
        <aura:attribute name="items" type="Camping_Item__c[]"/>
       
    <div class="slds-col slds-col--padded slds-p-top--small">
        <c:campingListForm />
    </div>
   
    <br/>
    <section class="slds-card__body">
    <div id="list" class="row">
        <aura:iteration items="{!v.items}" var="PerItem">
        <c:campingListItem item="{!PerItem}"/>
    </aura:iteration>
    </div>
    </section>
   
</aura:component>


CampingList(Controller).js (helper - is empty) 
({
    doInit  : function(component, event, helper) 
    {
               var action = component.get("c.getItems"); // c of apex controller
        action.setCallback(this, function(response)
        {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") 
            {
                component.set("v.items", response.getReturnValue());
            }
            else 
            {
            console.log("Failed with state: " + state);
               }
        });
        $A.enqueueAction(action);
        },
 
    handleAddItem : function (component,event,helper)
    {
               var action = component.get("c.saveItem");
        var item = event.getParam("item");
        var lstItems = component.get("v.items");
 
        action.setParams({"item":item});
        action.setCallback(this,function(response)
        {
               var state = response.getState();
               if (component.isValid() && state === "SUCCESS") 
               {
               lstItems.push(item);
               component.set("v.items",lstItems);
               console.log("After:"+lstItems);                
               }
        });
        $A.enqueueAction(action);   
    },
})



CampingListForm.cmp
<aura:component >
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
    <aura:attribute name="er" type="boolean" default="false"/>
    <aura:attribute name="newItem" type="Camping_Item__c"    default="{ 'sobjectType': 'Camping_Item__c',
                         'Name': '',
                         'Price__c': 0,
                         'Quantity__c': 0,                         
                         'Packed__c': false}"/>
 
        <form class="slds-form--stacked">          
         
                <lightning:input aura:id="Name" label="Camping Name"
                             name="name"
                             value="{!v.newItem.Name}"
                             required="true"/>
                     
                <lightning:input type="toggle" aura:id="Packed" label="Packed?"  
                             name="Packed"
                             checked="{!v.newItem.Packed__c}"/>
         
                <lightning:input type="number" aura:id="Price" label="Price"
                             name="Price"
                             min="0.1"
                             formatter="currency"
                             step="0.01"
                             value="{!v.newItem.Price__c}"
                             messageWhenRangeUnderflow="Enter an amount that's at least $0.10."/>
 
                <lightning:input type="number" aura:id="Quantity" label="Quantity"
                             name="Quantity"
                             value="{!v.newItem.Quantity__c}"
                             placeholder="ABC Co."/>
 
                <lightning:button label="Create Camping" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.clickCreateItem}"/>
        </form>
  
</aura:component>



CampingListForm(Controller).js
({
    clickCreateItem: function(component, event, helper) {  
        var a = component.get("v.newItem");
              
        helper.validateFields (component,component.find("Name"));
        helper.validateFields (component,component.find("Price"));
        helper.validateFields (component,component.find("Quantity"));
 
        var er = component.get("v.er");
        console.log(er);
 
        if(!er)
        {
            var newItem = component.get("v.newItem");            
            helper.CreateItem(component, newItem);
        }
      
        component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                        'Name': '',
                        'Quantity__c': 0,
                        'Price__c': 0,
                        'Packed__c': false });
    },
})


CampingListForm(Helper).js
({
    CreateItem : function(component, newItem) 
    {
        // creating event setting its parameters and fires it
        var createEvent = component.getEvent("addItem");
        // cleaning from fields
        component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                        'Name': '',
                        'Quantity__c': 0,
                        'Price__c': 0,
                        'Packed__c': false });
 
        createEvent.setParams({ "item": newItem });
        createEvent.fire();
    },
       
        validateFields : function (component,field) {
        var nameField = field;
        console.log('yes:'+nameField);
        var fieldname = nameField.get("v.value"); 
 
        if ($A.util.isEmpty(fieldname))
        {
           console.log('found empty nameField' + fieldname);
           component.set("v.er",true);
           nameField.set("v.errors", [{message:"this field can't be blank."}]);
        }
        else 
        {
            console.log('found nameField' + fieldname);
            nameField.set("v.errors", null);
        }
    },
 
})


CampingListItem.cmp
<aura:component >
       
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
    <aura:attribute type="Camping_Item__c" name="item" required="true"/>
   
    Name:
        <lightning:formattedText value="{!v.item.Name}" /><br/>
    Price:
    <lightning:formattedNumber value="{!v.item.Price__c}" style="currency"/><br/>
    Quantity:
    <lightning:formattedNumber value="{!v.item.Quantity__c}" /><br/>
    Packed:
    <lightning:input type="toggle" 
            label="Packed?"
            name="Packed"
            class="slds-p-around--small"
            checked="{!v.item.Packed__c}"
            messageToggleActive="Yes"
            messageToggleInactive="No"
            onchange="{!c.packItem}"/>
   
</aura:component>

CampingListController.apxc
public with sharing class CampingListController {
 
    @AuraEnabled
    public static List<Camping_Item__c> getItems() {
        return [SELECT Id, Name, price__c, Quantity__c, Packed__c 
                FROM Camping_Item__c];
    }
   
    @AuraEnabled
    public static Camping_Item__c saveItem(Camping_Item__c item) {
        system.debug('^^^the new item '+item);
        upsert item;
        return item;
    }
}



and camping class that includes campingHeader and campingList 
and i start it from harness.app

thank you
Naeh Orchay






 
Hello
i am a new to this platform and currently on the trail head tutorials,
i have encountered  in the section of "Get Started with Visualforce" with ForceUI app,
it apears to be an app to generate visualforce pages.
i wasnt able to locate ot in the appExchange does any1 knows where 2 find it? or is it released or depricated? 

User-added image

thank you

best regards

Naeh Orchay
I recieve an error when trying to download the app to complete this module 
App Issues
first of all hello : )
i working my way through the trailhead training and encountered a problem submitting this challenge.
the code itself works yet i get an error of :

Challenge Not yet complete... here's what's wrong: 
The campingList component doesn't appear to have a Quantity input field in the form using a Lightning Base component.


i guess its a default message for somthing else, any suggestion will be appreciated, i am posting my classes below,

CampingList.cmp
<aura:component controller="CampingListController">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}"/>
 
        <aura:attribute name="items" type="Camping_Item__c[]"/>
       
    <div class="slds-col slds-col--padded slds-p-top--small">
        <c:campingListForm />
    </div>
   
    <br/>
    <section class="slds-card__body">
    <div id="list" class="row">
        <aura:iteration items="{!v.items}" var="PerItem">
        <c:campingListItem item="{!PerItem}"/>
    </aura:iteration>
    </div>
    </section>
   
</aura:component>


CampingList(Controller).js (helper - is empty) 
({
    doInit  : function(component, event, helper) 
    {
               var action = component.get("c.getItems"); // c of apex controller
        action.setCallback(this, function(response)
        {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") 
            {
                component.set("v.items", response.getReturnValue());
            }
            else 
            {
            console.log("Failed with state: " + state);
               }
        });
        $A.enqueueAction(action);
        },
 
    handleAddItem : function (component,event,helper)
    {
               var action = component.get("c.saveItem");
        var item = event.getParam("item");
        var lstItems = component.get("v.items");
 
        action.setParams({"item":item});
        action.setCallback(this,function(response)
        {
               var state = response.getState();
               if (component.isValid() && state === "SUCCESS") 
               {
               lstItems.push(item);
               component.set("v.items",lstItems);
               console.log("After:"+lstItems);                
               }
        });
        $A.enqueueAction(action);   
    },
})



CampingListForm.cmp
<aura:component >
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
    <aura:attribute name="er" type="boolean" default="false"/>
    <aura:attribute name="newItem" type="Camping_Item__c"    default="{ 'sobjectType': 'Camping_Item__c',
                         'Name': '',
                         'Price__c': 0,
                         'Quantity__c': 0,                         
                         'Packed__c': false}"/>
 
        <form class="slds-form--stacked">          
         
                <lightning:input aura:id="Name" label="Camping Name"
                             name="name"
                             value="{!v.newItem.Name}"
                             required="true"/>
                     
                <lightning:input type="toggle" aura:id="Packed" label="Packed?"  
                             name="Packed"
                             checked="{!v.newItem.Packed__c}"/>
         
                <lightning:input type="number" aura:id="Price" label="Price"
                             name="Price"
                             min="0.1"
                             formatter="currency"
                             step="0.01"
                             value="{!v.newItem.Price__c}"
                             messageWhenRangeUnderflow="Enter an amount that's at least $0.10."/>
 
                <lightning:input type="number" aura:id="Quantity" label="Quantity"
                             name="Quantity"
                             value="{!v.newItem.Quantity__c}"
                             placeholder="ABC Co."/>
 
                <lightning:button label="Create Camping" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.clickCreateItem}"/>
        </form>
  
</aura:component>



CampingListForm(Controller).js
({
    clickCreateItem: function(component, event, helper) {  
        var a = component.get("v.newItem");
              
        helper.validateFields (component,component.find("Name"));
        helper.validateFields (component,component.find("Price"));
        helper.validateFields (component,component.find("Quantity"));
 
        var er = component.get("v.er");
        console.log(er);
 
        if(!er)
        {
            var newItem = component.get("v.newItem");            
            helper.CreateItem(component, newItem);
        }
      
        component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                        'Name': '',
                        'Quantity__c': 0,
                        'Price__c': 0,
                        'Packed__c': false });
    },
})


CampingListForm(Helper).js
({
    CreateItem : function(component, newItem) 
    {
        // creating event setting its parameters and fires it
        var createEvent = component.getEvent("addItem");
        // cleaning from fields
        component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                        'Name': '',
                        'Quantity__c': 0,
                        'Price__c': 0,
                        'Packed__c': false });
 
        createEvent.setParams({ "item": newItem });
        createEvent.fire();
    },
       
        validateFields : function (component,field) {
        var nameField = field;
        console.log('yes:'+nameField);
        var fieldname = nameField.get("v.value"); 
 
        if ($A.util.isEmpty(fieldname))
        {
           console.log('found empty nameField' + fieldname);
           component.set("v.er",true);
           nameField.set("v.errors", [{message:"this field can't be blank."}]);
        }
        else 
        {
            console.log('found nameField' + fieldname);
            nameField.set("v.errors", null);
        }
    },
 
})


CampingListItem.cmp
<aura:component >
       
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
    <aura:attribute type="Camping_Item__c" name="item" required="true"/>
   
    Name:
        <lightning:formattedText value="{!v.item.Name}" /><br/>
    Price:
    <lightning:formattedNumber value="{!v.item.Price__c}" style="currency"/><br/>
    Quantity:
    <lightning:formattedNumber value="{!v.item.Quantity__c}" /><br/>
    Packed:
    <lightning:input type="toggle" 
            label="Packed?"
            name="Packed"
            class="slds-p-around--small"
            checked="{!v.item.Packed__c}"
            messageToggleActive="Yes"
            messageToggleInactive="No"
            onchange="{!c.packItem}"/>
   
</aura:component>

CampingListController.apxc
public with sharing class CampingListController {
 
    @AuraEnabled
    public static List<Camping_Item__c> getItems() {
        return [SELECT Id, Name, price__c, Quantity__c, Packed__c 
                FROM Camping_Item__c];
    }
   
    @AuraEnabled
    public static Camping_Item__c saveItem(Camping_Item__c item) {
        system.debug('^^^the new item '+item);
        upsert item;
        return item;
    }
}



and camping class that includes campingHeader and campingList 
and i start it from harness.app

thank you
Naeh Orchay






 
Hi I got the following error while trying to do the Hands-on challenge for "Install a Managed Package in your Trailhead Playground"?

Is there something wrong with my trailhead org?  How may I fix it and proceed please?  Thanks

User-added image
User-added image
User-added image
User-added image

User-added image
Hello,
Can someone help me with module Metadata API, unit Build Admin Tools for Automated Configuration Changes?

The error I'm getting is:
Line 12: Method does not exist or incorrect signature; void add(Metadata.CustomMetadataValue) from the type List

Below is my code:
public class MetadataExample {

    public void updateMetadata () {
        Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
        customMetadata.fullName = 'MyNamespace__MyMetadataTypeName.MyMetadataRecordName';
        
        Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
        customField.field = 'customField__c';
        customField.value = 'New value';
        
        List <Metadata.CustomMetadata> mdtlist = new List<Metadata.CustomMetadata>();
        mdtlist.add(customField);  // Line 12
    }

}

I feel like I'm missing something very basic but I can't find any documentation specific to what I'm trying to do and the challenge is not similar (to me) to the example. Can someone please explain where I went wrong?
Hi,

I have inherited a VF page that uses the slds framework and I am trying to get my head around it.
I am fairly new to visual force, but I understand the logic in the site and the controller.
I did ask the developer the following question:

When using this component for example:

<div class="slds-page-header" role="banner">

Where do I find a reference about all the attributes that can be used in the page header class and what values are allowed ?
In other words, how do I know what values are allowed for the 'role'attribute above and are there any other attributes available for 'role' ?
The slds homepage doesn't seem to provide that information, at least I have not found it.

Many thanks

Michael
Hi All , getting the error while completing this module. While my application is running correctly.

Error: Challenge Not yet complete... here's what's wrong: The campingList JavaScript helper isn't saving the new record to the database or adding it to the 'items' value provider.

I am copying code for the finding the bug.

Apex Class:
public class CampingListController {
	@auraenabled
    public static List<Camping_Item__c> getItems (){
        List<Camping_Item__c> CI = [select id, name,price__c,Quantity__c,Packed__c from Camping_Item__c ];
        return CI;
    }
    @auraenabled
    public static Camping_Item__c saveItem (Camping_Item__c CampingItem){
        insert campingItem;
        return campingItem;
    }
}
CampingList.cmp
<aura:component controller="CampingListController">
    <aura:handler name = "init" value="{!this}" action = "{!c.doInit}"/>
	<aura:attribute name="items" type="Camping_Item__c[]"/>
    <aura:attribute name="er" type="boolean" default="false"/>
    <aura:attribute name="newItem" type="Camping_Item__c"    default="{ 'sobjectType': 'Camping_Item__c',
                         'Name': '',
                         'Price__c': 0,
                         'Quantity__c': 0,                         
                         'Packed__c': false
                       }"/>
    <ui:inputText value="{!v.newItem.Name}" aura:id="name" label="name"/>
    <ui:inputCheckbox value="{!v.newItem.Packed__c}" aura:id="Packed" label="Packed"/>
    <ui:inputCurrency value="{!v.newItem.Price__c}"  aura:id="Price" label="Price"/>
    <ui:inputNumber value="{!v.newItem.Quantity__c}" aura:id="Quantity" label="Quantity"/>
    <ui:button label="Create Expense" press="{!c.CreateCamping}" aura:id="button"/>
    <br/>
	<aura:iteration items="{!v.items}" var="PerItem">
        
        <c:campingListItem item="{!PerItem}" />
    </aura:iteration>
</aura:component>
CampingList.js
({
	
    doInit  : function(component, event, helper) {
		var action = component.get("c.getItems");
        action.setCallback(this, function(response){
            var state = response.getState();
           
            if (component.isValid() && state === "SUCCESS") {
           
               
                component.set("v.items", response.getReturnValue());
                 
            }
        });
        
        $A.enqueueAction(action);
	},
    
    CreateCamping : function(component, event, helper){
        
        helper.validateFields (component,component.find("name"));
        helper.validateFields (component,component.find("Price"));
        helper.validateFields (component,component.find("Quantity"));
        if(component.get("v.er") === false)
        {
            var lstItems = component.get("v.items");
            var Item = component.get("v.newItem");
            console.log('Before:'+lstItems);
            lstItems.push(Item);
            helper.CreateCampaign(component,Item);
            component.set("v.items",lstItems);  
             console.log('After:'+lstItems);
            component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                'Name': '',
                'Quantity__c': 0,
                'Price__c': 0,
                'Packed__c': false });
           
        }
	}
    
    
})

CampingListHelper.js
({
	
    validateFields : function (component,field) {
        
        var nameField = field;
        console.log('yes:'+nameField);
        var expname = nameField.get("v.value"); 
        if ($A.util.isEmpty(expname)){
           component.set("v.er",true);
           nameField.set("v.errors", [{message:"this field can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
    },
    
    CreateCampaign : function (component,Item){         
        var action = component.get("c.saveItem");
        action.setParams({"CampingItem":Item});
        action.setCallback(this,function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                console.log('save');
            }
        });
       $A.enqueueAction(action);        
    }
})
campingListItem.cmp
 
<aura:component >
    
   
    <aura:attribute type="Camping_Item__c" name="item" required="true"/>
    Name:
    <ui:outputText value="{!v.item.Name}" /><br/>
    Packed:
    <ui:outputCheckbox value="{!v.item.Packed__c}" /><br/>
    Price:
    <ui:outputCurrency value="{!v.item.Price__c}" /><br/>
   
    Quantity:
     <ui:outputNumber value="{!v.item.Quantity__c}" /><br/>
    
    <ui:button label="Packed!"  press="{!c.packItem}" aura:id = "Button"/> <br/>
</aura:component>

campingListItem.js
({
	    
    packItem : function(component, event, helper) {
		var pack = component.get("v.item");
        pack.Packed__c = true;
        component.set("v.item",pack);
        var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
        
	}
    
    
})


Help me out with it.

Thanks and Regards,
Sai Krishna Tavva.


 
Hi,

I can't pass the challenge (https://developer.salesforce.com/trailhead/force_com_dev_intermediate/lex_dev_lc_basics/lex_dev_lc_basics_events). This is the error when check challenge:

Challenge Not yet complete... here's what's wrong: 
The campingList JavaScript controller isn't adding the new record to the 'items' value provider.


I tryed in the browser add new Camping Items and it's working correctly. The item is added to database and the list is updated.

This is my code:

campingList Component
<aura:component controller="CampingListController">
    
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}"/>
    
    <div class="slds-page-header" role="banner">

      <div class="slds-grid">

        <div class="slds-col">

          <p class="slds-text-heading--label">Camping Items</p>

          <h1 class="slds-text-heading--medium">My Camping Items</h1>

        </div>

      </div>

    </div>

      
  <div aria-labelledby="newitemform">

      <fieldset class="slds-box slds-theme--default slds-container--small">
    
        <c:campingListForm />
    
      </fieldset>

	</div>
    
    
     <aura:attribute name="items" type="Camping_Item__c[]"/>

    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Camping List 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>

campingList Controller.js
({
    
    doInit: function(component, event, helper) {
    
        var action = component.get("c.getItems");
    
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.items", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
    
        $A.enqueueAction(action);
    },    
    
    handleAddItem: function(component, event, helper) {
        var item = event.getParam("item");
                
        var action = component.get("c.saveItem");
        action.setParams({
            "item": item
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {        
                var theItems = component.get("v.items");
                theItems.push(item);
                component.set("v.items",theItems);
            }
        });
        $A.enqueueAction(action);
    }
    
})

CampingListController
public with sharing class CampingListController {

    @AuraEnabled 
    public static List<Camping_Item__c> getItems() {
        return [SELECT Id, Name, Price__c, Quantity__c, Packed__c FROM Camping_Item__c];
    }
    
    @AuraEnabled
    public static Camping_Item__c saveItem(Camping_Item__c item) {
        upsert item;
        return item;
    }
}

CampingListForm Component
<aura:component >
    
     <aura:attribute name="newItem" type="Camping_Item__c"
     default="{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Packed__c': false,
                    'Price__c': '0',
                    'Quantity__c': '0' }"/>
	<aura:registerEvent name="addItem" type="c:addItemEvent"/>
    
  <div aria-labelledby="newitemform">
      <fieldset class="slds-box slds-theme--default slds-container--small">
    
        <legend id="newitemform" class="slds-text-heading--small 
          slds-p-vertical--medium">
          Add Camping Item
        </legend>
    
        <form class="slds-form--stacked">
    
          <div class="slds-form-element slds-is-required">
              <div class="slds-form-element__control">
                  <ui:inputText aura:id="name" label="Camping Item Name"
                      class="slds-input"
                      labelClass="slds-form-element__label"
                      value="{!v.newItem.Name}"
                      required="true"/>
              </div>
         </div>
            
          <div class="slds-form-element">
              <ui:inputCheckbox aura:id="packed" label="Packed?"
                  class="slds-checkbox"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Packed__c}"/>
          </div>
            
        <div class="slds-form-element">
              <div class="slds-form-element__control">
                  <ui:inputCurrency aura:id="price" label="Price"
                      class="slds-input"
                      labelClass="slds-form-element__label"
                      value="{!v.newItem.Price__c}" />
    
              </div>
          </div>
    
         <div class="slds-form-element">
              <div class="slds-form-element__control">
                  <ui:inputNumber aura:id="quantity" label="Quantity"
                      class="slds-input"
                      labelClass="slds-form-element__label"
                      value="{!v.newItem.Quantity__c}"/>
    
              </div>
          </div>
    
          <div class="slds-form-element">
              <ui:button label="Create Camping Item"
                  class="slds-button slds-button--brand"
                  press="{!c.clickCreateCampingItem}"/>
          </div>
    
        </form>
    
      </fieldset>
</div>

</aura:component>

CampingListForm Controller.js
({    
    
    clickCreateCampingItem : function(component, event, helper) {
        
        var validCamping = true;

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

        
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price) || isNaN(price) || (price <= 0.0)){
            validCamping = false;
            priceField.set("v.errors", [{message:"Camping Item price can't be blank."}]);
        }
        else {
            priceField.set("v.errors", null);
        }
        
        var quantityField = component.find("quantity");
        var quantity = quantityField.get("v.value");
        if ($A.util.isEmpty(quantity) || isNaN(quantity) || (quantity <= 0)){
            validCamping = false;
            quantityField.set("v.errors", [{message:"Camping Item quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }

        if(validCamping){
            
            helper.createItem(component);
            
        }
        
    },
})

CampingListForm Helper.js
({
    
     createItem : function(component) {
        var newItem = component.get("v.newItem");
        var addEvent = component.getEvent("addItem");
        addEvent.setParams({"item" : newItem});
        addEvent.fire();
        component.set("v.newItem",
                     { 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Packed__c': false,
                    'Price__c': 0,
                    'Quantity__c': 0});
    }
})

Could anyone help me?

Thanks,
Regards.

Hello Community, 

Having an issue with a Bulk Apex Trigger challenge here, hope you guys can assist. 

Here is the critieria:
To complete this challenge, you need to add a trigger for Opportunity. The trigger will add a task to any opportunity inserted or updated with the stage of 'Closed Won'. The task's subject must be 'Follow Up Test Task'.The Apex trigger must be called 'ClosedOpportunityTrigger'
With 'ClosedOpportunityTrigger' active, if an opportunity is inserted or updated with a stage of 'Closed Won', it will have a task created with the subject 'Follow Up Test Task'.
To associate the task with the opportunity, fill the 'WhatId' field with the opportunity ID.
This challenge specifically tests 200 records in one operation.

Here is the Error Received:
Challenge not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]

Here Is My Code:

trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {
 
    List<Task> taskList = new List<Task>();
         
    for(Opportunity opp : Trigger.new) {
         
        //Only create Follow Up Task only once when Opp StageName is to 'Closed Won' on Create
        if(Trigger.isInsert) {
            if(Opp.StageName == 'Closed Won') {
                taskList.add(new Task(Subject = 'Follow Up Test Task', WhatId = opp.Id));
                }
            }
             
            //Only create Follow Up Task only once when Opp StageName changed to 'Closed Won' on Update
            if(Trigger.isUpdate) {
                if(Opp.StageName == 'Closed Won'
                && Opp.StageName != Trigger.oldMap.get(opp.Id).StageName) {
                    taskList.add(new Task(Subject = 'Follow Up Test Task', WhatId = opp.Id));
                }
        }      
    }
     
        if(taskList.size()>0) {       
            insert taskList;       
    }   
}


Please Note: I appended the code from SumitKumar from another post which worked for others as I changed my code to suit the suggested code.above. It seems I may have an insert dml exception issue maybe caused by an earlier code insertion. PLEASE ADVISE

Any ideas as to what a SerializationException is? I could not find anything in the documentation.

Code:
Force.com Sandbox

Apex script unhandled exception by user/organization: 00550000000rTQA/00DT0000000EwRY

Visualforce Page: /apex/approveDealReg

System.SerializationException: Not Serializable: System.Savepoint

Class.approveDealRegVF.geterror: line 99, column 13

Debug Log:
***Begining Page Log for /apex/approveDealReg

Element j_id7 called method {!save} returned type PageReference: none20080610195821.020:Class.approveDealRegVF.getforwardOpp: line 76, column 16:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Split_Credit__c from method public SOBJECT:Split_Credit__c getforwardOpp() in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Opportunity from method public SOBJECT:Opportunity getexpirationDate() in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Task from method public SOBJECT:Task getreminderTask() in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Split_Credit__c from method public SOBJECT:Split_Credit__c getISR() in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Split_Credit__c from method public SOBJECT:Split_Credit__c getAE() in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Split_Credit__c from method public SOBJECT:Split_Credit__c getPBM() in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.getshowRegApproval: line 172, column 16:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.getshowRegApproval: line 172, column 65:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getshowRegApproval() in 0 ms
20080610195821.020:Class.approveDealRegVF.getShowFowardApproval: line 180, column 16:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.getShowFowardApproval: line 180, column 65:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getShowFowardApproval() in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getdisableAccount() in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getShowContact() in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getreminder() in 0 ms
20080610195821.020:Class.approveDealRegVF.getAccounts: line 201, column 43:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.getAccounts: line 201, column 92:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:External entry point:     returning LIST:System.SelectOption from method public LIST:System.SelectOption getAccounts() in 0 ms
20080610195821.020:External entry point:     returning String from method public String getaccountMergeID() in 0 ms
20080610195821.020:External entry point:     returning LIST:System.SelectOption from method public LIST:System.SelectOption getTerritories() in 0 ms
20080610195821.020:External entry point:     returning String from method public String getTerritoryID() in 0 ms
20080610195821.020:External entry point:     returning String from method public String getprimaryContact() in 0 ms
20080610195821.020:External entry point:     returning String from method public String getbody() in 0 ms
20080610195821.020:External entry point:     returning from end of method public void setaccountMergeID(String) in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getShowContact() in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Opportunity from method public SOBJECT:Opportunity getexpirationDate() in 0 ms
20080610195821.020:External entry point:     returning from end of method public void setReminder(Boolean) in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getreminder() in 0 ms
20080610195821.020:External entry point:     returning from end of method public void setTerritoryID(String) in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Split_Credit__c from method public SOBJECT:Split_Credit__c getISR() in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Split_Credit__c from method public SOBJECT:Split_Credit__c getAE() in 0 ms
20080610195821.020:External entry point:     returning SOBJECT:Split_Credit__c from method public SOBJECT:Split_Credit__c getPBM() in 0 ms
20080610195821.020:External entry point:     returning from end of method public void setprimaryContact(String) in 0 ms
20080610195821.020:External entry point:     returning from end of method public void setbody(String) in 0 ms
20080610195821.020:Class.approveDealRegVF.save: line 353, column 16:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.save: line 357, column 16:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.save: line 357, column 66:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.save: line 357, column 115:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.save: line 363, column 26: Creating savepoint: SavepointValue0
20080610195821.020:Class.approveDealRegVF.save: line 380, column 51: SOQL query with 3 rows finished in 9 ms
20080610195821.020:Class.approveDealRegVF.save: line 385, column 13: SelectLoop:LIST:SOBJECT:User
20080610195821.020:Class.approveDealRegVF.save: line 400, column 20:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.save: line 400, column 69:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.save: line 410, column 34:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.save: line 417, column 20:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.save: line 417, column 69:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.save: line 435, column 54: Database.convertLead(Database.LeadConvert)
20080610195821.020:Class.approveDealRegVF.save: line 435, column 54:     DML Operation executed in 7 ms
20080610195821.020:External entry point:     returning System.PageReference from method public System.PageReference save() in 23 ms
20080610195821.020:External entry point:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.getshowRegApproval: line 172, column 16:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.getshowRegApproval: line 172, column 65:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getshowRegApproval() in 1 ms
20080610195821.020:External entry point:     returning SOBJECT:Opportunity from method public SOBJECT:Opportunity getexpirationDate() in 0 ms
20080610195821.020:Class.approveDealRegVF.getShowFowardApproval: line 180, column 16:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.getShowFowardApproval: line 180, column 65:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getShowFowardApproval() in 1 ms
20080610195821.020:Class.approveDealRegVF.getAccounts: line 201, column 43:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:Class.approveDealRegVF.getAccounts: line 201, column 92:     returning SOBJECT:Lead from method public SOBJECT:Lead getsourceLead() in 0 ms
20080610195821.020:External entry point:     returning LIST:System.SelectOption from method public LIST:System.SelectOption getAccounts() in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getdisableAccount() in 0 ms
20080610195821.020:External entry point:     returning String from method public String getaccountMergeID() in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getShowContact() in 0 ms
20080610195821.020:External entry point:     returning Boolean from method public Boolean getreminder() in 0 ms
20080610195821.020:External entry point:     returning String from method public String geterror() in 0 ms

 


 



Message Edited by TehNrd on 06-10-2008 01:11 PM