• Mohammed CHOUKCHOU
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Hi how can i remove duplicate from list of object ! i try like this but it's doesn't work 
 
public static List<State__c> getState(){
        List <State__c> first = [SELECT Id,Name,Child__r.Name FROM State__c];
        List<State__c> uniqueValue = new List<State__c>();
        Set<State__c> myset = new Set<State__c>();
        for (State__cs : first) {
            if (myset.add(s)) {
                uniqueValue.add(s);
            }
        }
        return uniqueValue; 
    }

my list is like this :
 
suucces[{"Id":"a0b5E000002VSuXQAW","Name":"Abbes","Child__c":"a0Z5E000002s12BUAQ","Child__c":{"Name":"Abbes","Id":"a0Z5E000002s12BUAQ"},"Public__c":true},{"Id":"a0b5E000002VSajQAG","Name":"Abbes","Child__c":"a0Z5E000002s12BUAQ","Child__r":{"Name":"Abbes","Id":"a0Z5E000002s12BUAQ"},"Public__c":true}]
Hello everyone, I'm stuck at the last component challenge Aura,

I managed the challenge but when I try to insert a form in the database it makes me mistakes.

I tested with two submitform function
CampingListFormController.js
({
    submitForm: function(component, event, helper) {    
        if(helper.validateItemForm(component)){
            // Create the new item
            var newItem = component.get("v.newItem");
            helper.addItem(component, newItem);
        }
        
    },
    
    submitFormm: function(component, event, helper) {
        var validExpense = component.find('campingform').reduce(function (validSoFar, inputCmp) {
            // Displays error messages for invalid fields
            inputCmp.showHelpMessageIfInvalid();
            return validSoFar && inputCmp.get('v.validity').valid;
        }, true);
        // If we pass error checking, do some real work
        if(validExpense){
            // Create the new expense
            var newItem = component.get("v.newItem");
            helper.addItem(component, newItem);
        }
    }
    
})

for the first function SubmitForm (with only one "m" at the end) i have as error :
Action failed: c:campingListForm$controller$submitForm [Cannot read property 'get' of undefined] Failing descriptor: {c:campingListForm$controller$submitForm}

for the second function SubmitFormm (with two"m" at the end) i have as error :
Action failed: c:campingListForm$controller$submitFormm [component.getItem is not a function] Failing descriptor: {c:campingListForm$controller$submitFormm}

There is my campingListFormHelper.js
({
 addItem: function(component, newItem) {
    var addItem = component.getItem("addItem");
    addItem.setParams({ "item": item });
    addItem.fire();
            component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Quantity__c': 0,
                    'Price__c': 0,
                    'Packed__c': false });
},
    

		validateItemForm: function(component) {
		
              // 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 = nameField.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);
        }
		// Price must not be blank
        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);
        }
            return (validItem);

	}
})

 
Working through the Visualforce Mobile module  I want to do an exercise (3rd unit) that consists of displaying the contacts their names and phone numbers.
 
<apex:page showHeader="true" sidebar="true" standardController="Contact" recordSetVar="contacts">
<head>
<apex:slds />
</head>
<apex:repeat value="{!contacts}" var="c">
    <dl class="slds-list_horizontal slds-wrap">
        <dt class="slds-item_label slds-text-color_weak slds-truncate" title="Contact Name:">{!c.Name}</dt>
        <dd class="slds-item_detail slds-truncate" title="Mobile Phone Number:">{!c.Phone}</dd>
    </dl>
</apex:repeat>
 tried this code,I have no errors, however the list of contacts is not displayed! I tried to display a simple text it works, so the problem is at the level of the apex repeat I think
apex visualforce community slds
Working through the Visualforce Mobile module  I want to do an exercise (3rd unit) that consists of displaying the contacts their names and phone numbers.
 
<apex:page showHeader="true" sidebar="true" standardController="Contact" recordSetVar="contacts">
<head>
<apex:slds />
</head>
<apex:repeat value="{!contacts}" var="c">
    <dl class="slds-list_horizontal slds-wrap">
        <dt class="slds-item_label slds-text-color_weak slds-truncate" title="Contact Name:">{!c.Name}</dt>
        <dd class="slds-item_detail slds-truncate" title="Mobile Phone Number:">{!c.Phone}</dd>
    </dl>
</apex:repeat>
 tried this code,I have no errors, however the list of contacts is not displayed! I tried to display a simple text it works, so the problem is at the level of the apex repeat I think
apex visualforce community slds