• Mouhamed N'DIONGUE
  • NEWBIE
  • 47 Points
  • Member since 2016


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 10
    Replies

Hello, 

I am importing large sets of Data using Batch Apex from visualForce page. I have collected the list value from Class and calling batch apex just to do DML. 

Below is my code, 

Calling from class : 
SPL_BatchImportGild splTar = new SPL_BatchImportGild(FinalTarList);
Database.executeBatch(splTar);

Batch:

global class SPL_BatchImportGild implements Database.Batchable<SObject> , Database.Stateful 
{
global SObject[] queue; // = new list<Cycle_Plan_Target_vod__c>();
    
    global SPL_BatchImportGild(SObject[] recs)
    {
        queue=recs;
    }
    
    public static SObject[] start(Database.BatchableContext context) {
    {
        // need to pass the Queue value to execute. But showing error message 'Variable does not exist: queue'.
    }
    
    global static void execute(Database.BatchableContext context, SObject[] records) {
        insert records;
    }
    gloBal void finish(Database.BatchableContext context) 
    {
        
    }

What could be the reason for this.? 

Thanks 

Vignesh

Hello,
On this challenge there is a little mistake on the field Quantity__c that is labeled as "Quanity__c" missing one "T". I've lost some time as I always copy/paste the fields label when doing challenges. So could you correct that please. Thank you
Hi All,

I have the minutes and seconds field but need a time field to display HH:MM:SS. Please advice?

User-added image
 
Hi All.

Below class is used to create feeditem when application log is created/ updated.It's working fine when I am inserting/updating single record but it's creating only one record when multiple multiple records are created. Please let me know how to make this class to support multiple records. Thanks.

public class ApplicationLogTriggerHandler{
    public void LogHandlerMethod(List<Application_Log__c> appLogs){
        List<SObject> ObjList = new List<SObject>();
        String ObjType ='';
        String ObjID='';
        String Description = '';
        List<String> ObjTypeList = new List<String>();
        String LinkToRecord = '';
        List<Application_Log__c> LogList = new List<Application_Log__c>([Select ID, ObjectType__c, Name, Link_To_Record__c, 
                                                                         Record_Id__c, Description__c from 
                                                                         Application_Log__c where ID IN : appLogs ]);
        System.debug('LogList--->' +LogList);
        for(Application_Log__c app : LogList){
            if(app.Id!=null){
                ObjType = app.ObjectType__c;
                ObjID = app.Record_Id__c;
                Description = app.Description__c;
                LinkToRecord  = app.Link_To_Record__c;
                ObjTypeList.add(ObjType);
            }
        }
        system.debug('---->ObjTypeList'+ObjTypeList);
        System.debug('LogList--->' +LogList);
        String Query='Select Id, Name, LastModifiedById from '+ ObjType + ' WHERE ID =:ObjID';
        ObjList =database.query(Query); 
        System.debug('ObjList'+ ObjList);
        List<FeedItem> feedList = new List<FeedItem>();
            for(SObject record : ObjList){
            record.get('LastModifiedById');
            record.get('Name');
            System.debug((String) record.get('LastModifiedById'));
            FeedItem post = new FeedItem();
            post.ParentId = String.valueOf(record.get('LastModifiedById')); //eg. Opportunity id, custom object id..
            post.Body = 'An error has been logged for the opportunity: '+ record.get('Name') +  ' with the details: ' + Description + '\n' + 'Record ID: ' + LinkToRecord  ;
            feedList.add(post);
        }
        Database.insert(feedList, false);
        System.debug('feedList ------->' +feedList);
    }
}
Hi, 

I am having issues with contacts throwing a validation error once a in a while. Usually, we can get the contact to save, but only by removing either the Mailing City or Mailing State. There doesn't seem to be a pattern to the behavior. I contacted support, but they couldn't help me because the issue seems to be related to Apex Classes. Here's what the tech said:

As i investigated from my end and i can see -
1. There are no validation rules for contact and account
2. No workflow related to field (mailing city)
3. But i can see that there are many apex classes related to contact object and you need to check those apex classes, as we are not permitted to make any changes in you org.

We don't have an internal developer. And while we do have budget for some external development hours, I am wondering if there is a potentially simple fix for this issue. Can anyone let me know where to begin troubleshooting? I know how to use a sandbox and could potentially start working things out there.

Any advice is much appreciated! Thanks!

Hello, 

I am importing large sets of Data using Batch Apex from visualForce page. I have collected the list value from Class and calling batch apex just to do DML. 

Below is my code, 

Calling from class : 
SPL_BatchImportGild splTar = new SPL_BatchImportGild(FinalTarList);
Database.executeBatch(splTar);

Batch:

global class SPL_BatchImportGild implements Database.Batchable<SObject> , Database.Stateful 
{
global SObject[] queue; // = new list<Cycle_Plan_Target_vod__c>();
    
    global SPL_BatchImportGild(SObject[] recs)
    {
        queue=recs;
    }
    
    public static SObject[] start(Database.BatchableContext context) {
    {
        // need to pass the Queue value to execute. But showing error message 'Variable does not exist: queue'.
    }
    
    global static void execute(Database.BatchableContext context, SObject[] records) {
        insert records;
    }
    gloBal void finish(Database.BatchableContext context) 
    {
        
    }

What could be the reason for this.? 

Thanks 

Vignesh

I am unable to successfully login using the Salesforce DX CLI. I have tried numerous techniques, all to no avail. In am on Windows 10 utilizing the latest version of the CLI from Powershell and Google Chrome as my web browser.

As a side note, the "sfdx update" command works successfully.

Technique 1. When logging in using what is supposed to be the easiest approach by using force:auth:web:login, the CLI opens a web browser. Once I enter my credentials, the OAuth flow calls back into localhost:1717, but apparently the CLI isn't listening. Chrome complains with an ERR_EMPTY_RESPONSE and no response payload. Command line indicates "Unable to verify the first certificate." Turning on logging (even at the trace level) does not reveal any additional information.

Technique 2. I created a self-signed certificate using openssl along with a new connected app. Then using the CLI, I utilized the force:auth:jwt:grant function. This failed with the same error message as above: "Unable to verify the first certificate."

Technique 3. I disabled SSL verification and strict SSL in npm and forced the CLI to go through Fiddler. I then configured Fiddler to ignore certificate errors. Still, neither one of the above techniques worked after this.

Any idea what I'm doing wrong?
Hi everyone!
I have a problem with the challenge, my App work fine but I don´t pass the challenge. This is my code:

campingList.cmp:
 
<aura:component controller="CampingListController">
    
    <ltng:require styles="/resource/SLDS105/assets/styles/salesforce-lightning-design-system-ltng.css"/>

	<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
     <aura:attribute name="newItem" type="Camping_Item__c"
     default="{ 'sobjectType': 'Camping_Item__c',
                    'Price__c': 0,
                    'Quantity__c': 0}"/>
    
    <div class="slds-card slds-p-top--medium">
    <ui:inputText aura:id="campname" label="Camping Name"
        value="{!v.newItem.Name}" required="true"/>
    <ui:inputCheckbox aura:id="packed" label="Packed?"
        value="{!v.newItem.Packed__c}"/>
     <ui:inputCurrency aura:id="price" label="Price"
        value="{!v.newItem.Price__c}" required="true"/>
     <ui:inputNumber aura:id="quantity" label="Quantity"
        value="{!v.newItem.Quantity__c}" required="true"/>
    
    <ui:button label="Create Camping" press="{!c.clickCreateCamping}"/>
    </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">Campings</h3>
        </header>
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="item">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
            </div>
        </section>
    </div>
</aura:component>

campingListController.js:
 
({
    
    // Load expenses from Salesforce
	doInit: function(component, event, helper) {

    // Create the action
    var action = component.get("c.getItems");

    // Add callback behavior for when response is received
    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);
        }
    });

    // Send action off to be executed
    $A.enqueueAction(action);
	},
    
    clickCreateCamping: function(component, event, helper) {
        
        if(helper.validateCampingForm(component)){
	        // Create the new expense
	        var newCamping = component.get("v.newItem");
	        helper.createItem(component, newCamping);
	    }
    }
})
campingListHelper.js
 
({
    
    createItem: function(component, camping) {
        
        var action = component.get("c.saveItem");
        action.setParams({
            "item": camping
        });
    	action.setCallback(this, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            var campings = component.get("v.items");
            campings.push(response.getReturnValue());
            component.set("v.items", campings);
        }
    	});
    	$A.enqueueAction(action);
    },
    
    validateCampingForm: function(component) {
      
     	var validQuantity = true;
        var validPrice = true;

        var nameField = component.find("campname");
        var campname = nameField.get("v.value");
        
        var quantityField = component.find("quantity");
        var quantity = quantityField.get("v.value");
        
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        
        if ($A.util.isEmpty(campname) || $A.util.isEmpty(quantity) || $A.util.isEmpty(price)){
            validQuantity = false;
            validPrice = false;
            nameField.set("v.errors", [{message:"Camping name, quantity or price can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
		
		return(validQuantity && validPrice);        
	}
})
CampingListController.apxc:
 
public with sharing class CampingListController {

    @AuraEnabled
    public static List<Camping_Item__c> getItems() {
    
        // Check to make sure all fields are accessible to this user
        String[] fieldsToCheck = new String[] {
            'Id', 'Name', 'Packed__c', 'Price__c', 'Quantity__c'
        };
        
        Map<String,Schema.SObjectField> fieldDescribeTokens = 
            Schema.SObjectType.Camping_Item__c.fields.getMap();
        
        for(String field : fieldsToCheck) {
            if( ! fieldDescribeTokens.get(field).getDescribe().isAccessible()) {
                throw new System.NoAccessException();
                return null;
            }
        }        
        
        // Perform isAccessible() checking first, then
        return [SELECT Id, Name, Packed__c, Price__c, Quantity__c 
                FROM Camping_Item__c];
    }
    
    @AuraEnabled
    public static Camping_Item__c saveItem(Camping_Item__c item) {
        // Perform isUpdatable() checking first, then
        upsert item;
        return item;
    }
}
I am still getting this 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.


My App save the new record into the database and add it to the "items" list.
Thanks for your answers!




 
Challenge - Create a form to enter new items and display the list of items entered. To make our camping list look more appealing, change the campingHeader component to use the SLDS. Similar to the unit, style the Camping List H1 inside the slds-page-header. Modify the campingList component to contain an input form and an iteration of campingListItem components for displaying the items entered.
The component requires an attribute named items with the type of an array of camping item custom objects.
The component requires an attribute named newItem of type Camping_Item__c with default quantity and price values of 0.
The component displays the Name, Quantity, Price, and Packed form fields with the appropriate input component types and values from the newItem attribute.
The JavaScript controller checks to ensure that the Name, Quantity and Price values submitted are not null.
If the form is valid, the JavaScript controller pushes the newItem onto the array of existing items, triggers the notification that the items value provider has changed, and resets the newItem value provider with a blank sObjectType of Camping_Item__c.


My answer - 
<aura:component >
<aura:attribute name="items" type="Camping_Item__c[]"/>
<aura:attribute name="newitem" type="Camping_Item__c[]"  default="{ 'sobjectType': 'Camping_Item__c',
                   'Quantity__c'=0, 'Price__c'=0}"/>
 <p>Name:
        <ui:inputText value="{!v.newitem.name}"/>
    </p>    
  <p>Packed:
        <ui:inputCheckbox value="{!v.newitem.Packed__c}"/>
     
    </p>    
  <p>Price:
        <ui:inputCurrency value="{!v.newitem.Price__c}"/>
    </p>
    <p>Quantity:
        <ui:inputNumber value="{!v.newitem.Quantity__c}"/>
    </p>
</aura:component>


Error -

Challenge Not yet complete... here's what's wrong: 
The campingList component isn't iterating the array of 'items' and creating 'campingListItem' components.

Please share the correct solution.
Hello,
On this challenge there is a little mistake on the field Quantity__c that is labeled as "Quanity__c" missing one "T". I've lost some time as I always copy/paste the fields label when doing challenges. So could you correct that please. Thank you
Hi everyone!
I have a problem with the challenge, my App work fine but I don´t pass the challenge. This is my code:

campingList.cmp:
 
<aura:component controller="CampingListController">
    
    <ltng:require styles="/resource/SLDS105/assets/styles/salesforce-lightning-design-system-ltng.css"/>

	<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
     <aura:attribute name="newItem" type="Camping_Item__c"
     default="{ 'sobjectType': 'Camping_Item__c',
                    'Price__c': 0,
                    'Quantity__c': 0}"/>
    
    <div class="slds-card slds-p-top--medium">
    <ui:inputText aura:id="campname" label="Camping Name"
        value="{!v.newItem.Name}" required="true"/>
    <ui:inputCheckbox aura:id="packed" label="Packed?"
        value="{!v.newItem.Packed__c}"/>
     <ui:inputCurrency aura:id="price" label="Price"
        value="{!v.newItem.Price__c}" required="true"/>
     <ui:inputNumber aura:id="quantity" label="Quantity"
        value="{!v.newItem.Quantity__c}" required="true"/>
    
    <ui:button label="Create Camping" press="{!c.clickCreateCamping}"/>
    </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">Campings</h3>
        </header>
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="item">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
            </div>
        </section>
    </div>
</aura:component>

campingListController.js:
 
({
    
    // Load expenses from Salesforce
	doInit: function(component, event, helper) {

    // Create the action
    var action = component.get("c.getItems");

    // Add callback behavior for when response is received
    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);
        }
    });

    // Send action off to be executed
    $A.enqueueAction(action);
	},
    
    clickCreateCamping: function(component, event, helper) {
        
        if(helper.validateCampingForm(component)){
	        // Create the new expense
	        var newCamping = component.get("v.newItem");
	        helper.createItem(component, newCamping);
	    }
    }
})
campingListHelper.js
 
({
    
    createItem: function(component, camping) {
        
        var action = component.get("c.saveItem");
        action.setParams({
            "item": camping
        });
    	action.setCallback(this, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            var campings = component.get("v.items");
            campings.push(response.getReturnValue());
            component.set("v.items", campings);
        }
    	});
    	$A.enqueueAction(action);
    },
    
    validateCampingForm: function(component) {
      
     	var validQuantity = true;
        var validPrice = true;

        var nameField = component.find("campname");
        var campname = nameField.get("v.value");
        
        var quantityField = component.find("quantity");
        var quantity = quantityField.get("v.value");
        
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        
        if ($A.util.isEmpty(campname) || $A.util.isEmpty(quantity) || $A.util.isEmpty(price)){
            validQuantity = false;
            validPrice = false;
            nameField.set("v.errors", [{message:"Camping name, quantity or price can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
		
		return(validQuantity && validPrice);        
	}
})
CampingListController.apxc:
 
public with sharing class CampingListController {

    @AuraEnabled
    public static List<Camping_Item__c> getItems() {
    
        // Check to make sure all fields are accessible to this user
        String[] fieldsToCheck = new String[] {
            'Id', 'Name', 'Packed__c', 'Price__c', 'Quantity__c'
        };
        
        Map<String,Schema.SObjectField> fieldDescribeTokens = 
            Schema.SObjectType.Camping_Item__c.fields.getMap();
        
        for(String field : fieldsToCheck) {
            if( ! fieldDescribeTokens.get(field).getDescribe().isAccessible()) {
                throw new System.NoAccessException();
                return null;
            }
        }        
        
        // Perform isAccessible() checking first, then
        return [SELECT Id, Name, Packed__c, Price__c, Quantity__c 
                FROM Camping_Item__c];
    }
    
    @AuraEnabled
    public static Camping_Item__c saveItem(Camping_Item__c item) {
        // Perform isUpdatable() checking first, then
        upsert item;
        return item;
    }
}
I am still getting this 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.


My App save the new record into the database and add it to the "items" list.
Thanks for your answers!