• Bhupendra Kshatri 6
  • 5 Points
  • Member since 2015
  • Developer
  • Cloud9Force Ltd, United Kingdom

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
  • 4
In this Trailhead, the questions ofo section 2 are being checked in section1 , questions of section 3 in section 2 and so on. Please correct.
Hello All,

I have a requirement where when a sales agent is going to meet an appointment with client A, he must be able to find out other clients within 20 minutes drive distance from the the Client A so that he can meet them as well when he is in that area. If anyone can guide me to approach solution for this please.

Many Thanks

So i am trying to implement the "Infinite Scrolling to Load More Rows" in a datatable.  I am trying to implement the example found at https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_datatable.htm.  However there is a helper method called in the JS Controller called "fetchData" that is not there and i cant for the life of me make it myself.  I have tried everything.  Any help would be greatly appreciated.

Please see code below.

<aura:component controller="ContactController" implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
    <aura:attribute name="mydata" type="Object" />
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="isLoading" type="Boolean" default="true"/>
    <aura:attribute name="contactId" type="Id" />
    <aura:attribute name="sortedBy" type="String" />
    <aura:attribute name="sortedDirection" type="String" /> 
    <aura:attribute name="enableInfiniteLoading" type="Boolean" default="true"/>
    <aura:attribute name="initialRows" type="Integer" default="10"/>
    <aura:attribute name="rowsToLoad" type="Integer" default="50"/>
    <aura:attribute name="totalNumberOfRows" type="Integer" default="300"/>
    <aura:attribute name="loadMoreStatus" type="String" default=""/>
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <div style="height: 500px">
        <lightning:datatable data="{! v.mydata}" 
                             columns="{! v.mycolumns }" 
                             onloadmore="{! c.loadMoreData }"/>
    {! v.loadMoreStatus}

JS Controller:

    init: function (cmp, event, helper) {

        var actions = [
            { label: 'Show details', name: 'show_details' },
            { label: 'Delete', name: 'delete' }
        cmp.set('v.mycolumns', [
            // Other column data here
            { type: 'action', typeAttributes: { rowActions: actions } }
        cmp.set('v.mycolumns', [
            {label: 'Contact Name', fieldName: 'Name', type: 'string', sortable: 'true'},
            {label: 'Phone', fieldName: 'Phone', type: 'phone', sortable: 'true'},
            {label: 'Email', fieldName: 'Email', type: 'email', sortable: 'true'}
    getSelectedName: function (cmp, event) {
        var selectedRows = event.getParam('selectedRows');
        // Display that fieldName of the selected rows
        for (var i = 0; i < selectedRows.length; i++){
            alert("You selected: " + selectedRows[i].Name);
    handleRowAction: function (cmp, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        switch (action.name) {
            case 'show_details':
                alert('Showing Details: ' + JSON.stringify(row));
                cmp.set('v.contactId', row.Id);
                var attribute1 = cmp.get('v.contactId');
                var childComponent = cmp.find('child');
            case 'delete':
                var rows = cmp.get('v.mydata');
                var rowIndex = rows.indexOf(row);
                rows.splice(rowIndex, 1);
                cmp.set('v.mydata', rows);
    //Client-side controller called by the onsort event handler
    updateColumnSorting: function (cmp, event, helper) {
        var fieldName = event.getParam('fieldName');
        var sortDirection = event.getParam('sortDirection');
        // assign the latest attribute with the sorted column fieldName and sorted direction
        cmp.set("v.sortedBy", fieldName);
        cmp.set("v.sortedDirection", sortDirection);
        helper.sortData(cmp, fieldName, sortDirection);     
    loadMoreData: function (cmp, event, helper) {
        //Display a spinner to signal that data is being loaded
        event.getSource().set("v.isLoading", true);
        //Display "Loading" when more data is being loaded
        cmp.set('v.loadMoreStatus', 'Loading');
        helper.fetchData(cmp, cmp.get('v.rowsToLoad'))
            .then($A.getCallback(function (data) {
                if (cmp.get('v.mydata').length >= cmp.get('v.totalNumberOfRows')) {
                    cmp.set('v.enableInfiniteLoading', false);
                    cmp.set('v.loadMoreStatus', 'No more data to load');
                } else {
                    var currentData = cmp.get('v.mydata');
                    //Appends new data to the end of the table
                    var newData = currentData.concat(data);
                    cmp.set('v.mydata', newData);
                    cmp.set('v.loadMoreStatus', '');
               event.getSource().set("v.isLoading", false);


This is where i need the help to come up with a helper method that is referenced in the JS controller.  THANK YOU!


I need to write a trigger on base of a field value:

I have three objects:
Call__c -- Master object
Call_Objective__c -- detail object
Call_Asset__c -- detail object

In Call__c I have a picklist field called Status__c which have values like "In Progress", "Not Started" and "Completed".

Now my requirement is, I need to write a trigger that prevents updating of Call__c and creating, updating and deleting of  Call_Objective__c and Call_Asset__c records when Status__c is set to "Completed"

Thanks in Advance
Error -
A problem with the OnClick JavaScript for this button or link was encountered:missing ; before statement

setting for custom button

Display Type    
Detail Page Button View example

Execute java script

content source
Onclick javascript

Code -

    var taskToCreate = new sforce.SObject("Task");
    taskToCreate.OwnerId = "{!$User.Id}";
    taskToCreate.WhoId = "{!Lead.Id}";
    taskToCreate.Subject = "Voicemail";
    taskToCreate.ActivityDate = new Date();

    taskToCreate.Priority = "Normal";
    taskToCreate.Status = "Completed";

taskToCreate.Division__c = "Verdantis";
    result = sforce.connection.create([taskToCreate]);

var newRecords = [];
 var leadstatusupdate = new sforce.SObject("Lead");
  leadstatusupdate.Lead ID = "{!Lead.Id}";
 leadstatusupdate.Status = "Open - Voicemail / Email";
  result = sforce.connection.update([leadstatusupdate]);
"{!Lead.Status}" === "Open - Not Contacted" ||
"{!Lead.Status}" === "Archive" &&
"{!Lead.Archive_Reason__c}" === "No Plans - Till Next 6 months" ||
"{!Lead.Archive_Reason__c}" === "No Plans - Till Next year"
leadstatusupdate.Status = "Open - Voicemail / Email";


result = sforce.connection.update(newRecords);

    if(result[0].success == "true"){
            "An Error has Occurred. Error: \r\n" +
        "An Un-expected Error has Occurred. Error: \r\n" +


We found that we have a lot of cases not related to any accounts. This happens because from a case it is possible to create a contact without relating it to an account.
We need to stop this and we are looking for a resolution to this issue.  I know that we could set a validation rule to not save the case when an account is not present but I would like to directly be able to chanhge the Contact creation page adding the account info on it

Any helps will be appreciated

Michela Bovio