• Lokesh Krishna Sagi
  • NEWBIE
  • 35 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 5
    Questions
  • 10
    Replies
Hi All,

I am trying to authorize an org (Dev org not sandbox) from VS Code and I am in my Company network and default port Id 1717 wouldnt work for me. I have followed the below steps to create a Connected App and change port number in sfdx-project.json file. But still its taking me to old 1717 localhost even after changin the port number.

From Connected App..
User-added image

From VSCode project setup..

User-added image

I have also tried to put 443 in the redirected URL instead of 1717. But it doesnt work either.

Is there any mistake that I have done while setting up the Conncted App ? BTW, I am not using JWT AUthentication. Its just web based authentication. How else can I change the default port number ?

PS : I have used both "oauthLocalPort" : "443" and "oauthLocalPort" : 443. 
 
Hi,

I am trying to work out features of lightning dataTable and I am currently stuck at inline edit feature. I have created 2 components (both are independent) for 2 inline edit examples. 1st one is working as expected but the 2nd component is not working. 

Whenever I change some value in any row, it is suppossed to call Server controller. But my code never reaching server controller.. I am posting the entire code here. Please Help!!
Component
-------------------

<aura:component controller = "AdvancedORCASearchClass" 
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="searchData" type="Object" />
    <aura:attribute name="data" type="List" default="[]" />
    <aura:attribute name="columns" type="List" />
    <aura:attribute name="mySelectedRows" type="Object[]" />
    <aura:attribute name="selectedRowsCount" type="Integer" default="0" />
    <aura:attribute name="maxRowSelection" type="Integer" default="5"/>
    <aura:attribute name="isButtonEnabled" type="boolean" default="false" />
    
    <aura:attribute name="selectedIds" type="List" />
    
    <aura:attribute name="allData" type="List"/>
    <aura:attribute name="rowsToDisplay" type="Integer" default="7" />
    <aura:attribute name="totalPages" type="Integer" />
    <aura:attribute name="currentPageNumber" type="Integer" default="1"/>
    
    <aura:attribute name="enableInfiniteLoading" type="boolean" default="true" />
    <aura:attribute name="totalRows" type="Integer" />
    <aura:attribute name="offsetNumber" type="Integer" default="0" />
    <aura:attribute name="initialRows" type="Integer" default="7" />
    <aura:attribute name="isLoading" type="boolean" default="false" />
    <aura:attribute name="loadMoreStatus" type="String" default="" />
    
    
    <aura:attribute name="selection" type="List" access="PRIVATE"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <!-- <aura:handler event="c:AdvORCASendRecordId" action="{!c.refreshComponent}" />  -->
    <!--    <aura:handler event="force:refreshView" action="{!c.doInit}" /> -->
    
    <aura:method name="search" action="{!c.getSearchResult}">
        <aura:attribute name="fromDate" type="Date"/>
        <aura:attribute name="toDate" type="Date" />
        <aura:attribute name="selectedStatuses" type="String[]" />
        
    </aura:method>
    
    <lightning:navigation aura:id="navService" />
    
    <aura:if isTrue="{!v.isButtonEnabled}">
        <lightning:layout horizontalAlign="center">
            <lightning:layoutItem  padding="around-large">
                
                <lightning:button iconName="action:download" iconPosition="right" label="Download Selected" onclick="{!c.onDownload}" 
                                  variant="brand" />
                
            </lightning:layoutItem>
        </lightning:layout>
    </aura:if>
    
    <lightning:layout horizontalAlign="center" multipleRows="true">
        
        <lightning:layoutItem size="12">
            <div style="height: 300px">
                <lightning:dataTable  
                                     aura:id="dataTable"
                                     columns="{!v.columns}"
                                     data="{!v.data}"
                                     keyField="id"
                                     enableInfiniteLoading="{!v.enableInfiniteLoading}"
                                     onloadmore="{!c.loadMoreData}"
                                     isLoading="{!v.isLoading}"
                                     hideCheckboxColumns="false"
                                     onrowaction="{!c.handleRowAction}"
                                     maxRowSelection="{! v.maxRowSelection }"
                                     onrowselection="{! c.updateSelectedText }" 
                                     onsave="{! c.onSave}"
                                     />
            </div>
        </lightning:layoutItem>
        
        <aura:if isTrue="{!v.isButtonEnabled}">
            <lightning:layoutItem size="12" class="centerAlign">
                {!v.loadMoreStatus}
            </lightning:layoutItem>
            

    </lightning:layout>
    
</aura:component>
-----------------------------------------------------------------------------------------

Client Controller
---------------------------

({
    getSearchResult : function(component, event, helper) {
        component.set('v.data', []); 
        component.set('v.offsetNumber', 0);
        component.set('v.enableInfiniteLoading', true);
        //$A.get('e.force:refreshView').fire();
        var parameters = event.getParam('arguments');
        //alert('Data is set to [] here');
        if(parameters) {
            component.set('v.searchData', parameters); 
            
            //alert('Params are set here. To Helpers');
            
            helper.getTotalRows(component, event, helper);
            
            //alert('Helper1 is done');
            
            helper.getSearchResults(component, event, helper, component.get('v.offsetNumber'));
            //alert('Helper2 is done. Data size=='+component.get('v.data').length);
        }
    },
    
    /* refreshComponent : function(component, event, helper) {
        $A.get('e.force:refreshView').fire();
    }, */
    
    doInit : function(component, event, helper) {
        //component.set('v.data', []);
        //alert('length===='+component.get('v.data').length);
        
        var actions = [{label:"Change Status", name:"update_Status"},
                       {label:"Delete", name:"delete"}];        
        component.set('v.columns', [
            {label:"Incident Number", fieldName:"Name", type:"text"},
            {label:"View", type:"button", typeAttributes:{label:"View", name:"view_details", title:"Click here to View Details"}},
            {label:"Title", fieldName:"Title__c", type:"text", editable:true},
            {label:"Date", fieldName:"Incident_Date__c", type:"Date"},
            {label:"Risk Category", fieldName:"Risk_Category__c", type:"text"},
            {label:"Status", fieldName:"Status__c", type:"text"},
            {label:"Ops Risk Region", fieldName:"Ops_Risk_Region__c", type:"text"},
            {label:"Recorder", fieldName:"linkNameRec", type:"url", typeAttributes:{label:{fieldName:"Recorder__c"}, target:"_blank"}},
            {label:"Reviewer", fieldName:"linkNameRev", type:"url", typeAttributes:{label:{fieldName:"Reviewer__c"}, target:"_blank"}},
            {label:"Approver", fieldName:"linkNameApp", type:"url", typeAttributes:{label:{fieldName:"Approver__c"}, target:"_blank"}},
            {type:'action', typeAttributes:{rowActions:actions}}
        ]);
    },
    
    handleRowAction : function(component, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        switch (action.name) {
            case 'view_details':
                var navEvent = $A.get("e.force:navigateToSObject");
                if(navEvent) {
                    navEvent.setParams({
                        "recordId" : row.Id,
                        "slideDevName" : "detail"
                    });
                    window.open('/'+event.getParam('row').Id);
                }
                break;
                
            case 'delete':
                alert('Please dont delete me....');
                break;
                
            case 'update_Status':
                /*var appEvent = $A.get('e.c:AdvORCASendRecordId');
                appEvent.setParams({
                    "recordId":row.Id
                });
                alert('Before Firing');
                appEvent.fire();
                alert('After Firing'); */
                var navService = component.find('navService');
                var pageReference = {
                    "type":"standard__component", 
                    "attributes":{"componentName":"c__AdvancedORCAChangeStatus"},
                    "state":{recordId:row.Id}};
                navService.navigate(pageReference);
                //alert('KeyField:::'+row.keyField);
                
                break;
        }
    },
    
    onDownload : function(component, event, helper) {
        //alert('Selected Rows::'+component.get('v.mySelectedRows'));
        var stockData = component.get('v.mySelectedRows');
        
        if(stockData.length == 0) {
            alert('Please select at least one row to export results');
        }
        else {
            var csv = helper.convertArrayOfObjectsToCSV(component,stockData);
            
            if (csv == null){
                return;
            } 
            
            var hiddenElement = document.createElement('a');
            hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
            hiddenElement.target = '_self'; // 
            hiddenElement.download = 'ExportData.csv';  // CSV file Name* you can change it.[only name not .csv] 
            document.body.appendChild(hiddenElement); // Required for FireFox browser
            hiddenElement.click(); // using click() js function to download csv file
        }
        
    },
    
    updateSelectedText : function(component, event, helper) {
        //component.set('v.selectedIds', component.find('dataTable').get('v.keyField').Id);
        // alert('Selected IDs::'+component.get('v.selectedIds'));
        var selectedRows = event.getParam('selectedRows');
        component.set('v.mySelectedRows', selectedRows);
        
    },
   
    
    loadMoreData : function(component, event, helper) {
        //alert('Success untill here');
        //event.getSource().set("v.isLoading", true);
        component.set('v.isLoading', true);
        component.set('v.loadMoreStatus', 'Loading');
        component.set('v.offsetNumber', component.get('v.data').length);
        //alert('offset::'+component.get('v.offsetNumber'));
        helper.getSearchResults(component, event, helper, component.get('v.offsetNumber'));
    },
    
    onSave : function(component, event, helper) {
       // var editedRecords = component.find('dataTable').get('v.draftValues');
      //  alert('Number of records edited:'+editedRecords.length);
        helper.onEdit(component, event, helper);
    }
})
----------------------------------------------------------------------------------------------

Helper
--------------------
({
    getSearchResults : function(component, event, helper, offNumber) {
        //alert('Inside Helper');
        //alert('Offset Number::'+offNumber);
        var action1 = component.get('c.searchWithInputs');
        action1.setParams({
            fromDate:component.get('v.searchData').fromDate,
            toDate:component.get('v.searchData').toDate,
            statuses:component.get('v.searchData').selectedStatuses,
            rowsToDisplay:component.get('v.rowsToDisplay'),
            offsetNumber:offNumber
        });        
        action1.setCallback(this, function(response) {
            var state = response.getState();
            
            if(state==='SUCCESS') {
                //alert('Inside For');
                for(var i=0; i<response.getReturnValue().length; i++) {
                    // alert('Inside For');
                    var row = response.getReturnValue()[i];
                    
                    row.linkNameRec = "/"+row.Recorder__c;
                    row.Recorder__c = row.Recorder__r.Name;
                    
                    row.linkNameRev = "/"+row.Reviewer__c;
                    row.Reviewer__c = row.Reviewer__r.Name;
                    
                    row.linkNameApp = "/"+row.Approver__c;
                    row.Approver__c = row.Approver__r.Name;   
                }
                
                if(component.get('v.data').length >= component.get('v.totalRows')) {
                    component.set('v.enableInfiniteLoading', false);
                    component.set('v.loadMoreStatus', 'No more records to load.');
                }
                else {
                    var currentData = component.get('v.data');
                    var newData = currentData.concat(response.getReturnValue());
                    component.set('v.data', newData);
                    component.set('v.loadMoreStatus', '');   
                    //alert('Alert for length++++'+component.get('v.data').length);
                }
                component.set('v.isLoading', false);
                //event.getSource().set("v.isLoading", false);
                
                
                //component.set('v.totalPages', Math.ceil(response.getReturnValue().length/component.get('v.rowsToDisplay')));
                // component.set('v.data', response.getReturnValue());
                // component.set('v.currentPageNumber',1);
                
                if(component.get('v.isButtonEnabled') == false) {
                    component.set('v.isButtonEnabled', true);
                }
                
                
                //  helper.setData(component, event, helper);
            }
        });
        $A.enqueueAction(action1);
    },
    
    getTotalRows : function(component, event, helper) {
        var action2 = component.get('c.getCountIncidents');
        action2.setParams({
            fromDate:component.get('v.searchData').fromDate,
            toDate:component.get('v.searchData').toDate,
            statuses:component.get('v.searchData').selectedStatuses
            
        });    
        action2.setCallback(this, function(response) {
            var state = response.getState();
            
            if(state==='SUCCESS') {
                component.set('v.totalRows', response.getReturnValue().length);
            }
        });
        $A.enqueueAction(action2);
    },
    
    
    /* 
    setData : function(component, event, helper) {
        var data = [];
        var pageNumber = component.get('v.currentPageNumber');
        var totalPages = component.get('v.totalPages');
        var rowsToDisplay = component.get('v.rowsToDisplay');
        var allData = component.get('v.allData');
        
        var x = (pageNumber-1)*rowsToDisplay;
        
        for(;x<=(pageNumber)*(rowsToDisplay);x++) {
            if(allData[x]) {
                data.push(allData[x]);
            }
        }
        component.set('v.data', data);
    },
    */
    convertArrayOfObjectsToCSV : function(component, objectRecords) {
        var csvStringResult, counter, keys, columnDivider, lineDivider;
        if(objectRecords == null && !objectRecords.length) {
            return null;
        }
        columnDivider = ',';
        lineDivider = '\n';
        keys = ['Name', 'Title__c', 'Incident_Date__c', 'Risk_Category__c', 'Status__c', 'Ops_Risk_Region__c',
                'Recorder__c', 'Reviewer__c', 'Approver__c'];
        csvStringResult = '';
        csvStringResult += keys.join(columnDivider);
        csvStringResult += lineDivider;
        
        for(var i=0; i<objectRecords.length; i++) {
            counter = 0;
            for(var sTempkey in keys) {
                var skey = keys[sTempkey] ;  
                
                
                if(counter > 0){ 
                    csvStringResult += columnDivider; 
                }   
                
                csvStringResult += '"'+ objectRecords[i][skey]+'"'; 
                
                counter++;
                
            } 
            csvStringResult += lineDivider;
        }
        
        //alert('Returning thing:::'+csvStringResult);
        return csvStringResult; 
    },
    
    onEdit : function(component, event, helper) {
        var editedRecords = event.getParam('draftValues');
        var totalRecordEdited = editedRecords.length;
        
        var action = component.get("c.updateRecords");
        
        action.setParams({
            "editedAccounts" : editedRecords
        });
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === 'SUCCESS') {
                
                if(response.getReturnValue() === true) {
                    helper.showToast({
                        "title" : 'Record Update',
                        "type" : "success",
                        "message" : totalRecordEdited + " Records updated"
                    });
                    helper.reloadDataTable();
                }
                else {
                    helper.showToast({
                        "title": "Error!!",
                        "type": "error",
                        "message": "Error in update"
                    });
                }
            }
        });
        
        $A.enqueueAction(action);
    },
    
    showToast : function(params){
        var toastEvent = $A.get("e.force:showToast");
        if(toastEvent){
            toastEvent.setParams(params);
            toastEvent.fire();
        } else{
            alert(params.message);
        }
    },
    
    reloadDataTable : function(){
    var refreshEvent = $A.get("e.force:refreshView");
        if(refreshEvent){
            refreshEvent.fire();
        }
    },
    
})
---------------------------------------------------------------------------------------------------

Server Controller -- Apex Class
-----------------------------------------
public class AdvancedORCASearchClass {
    @AuraEnabled
    public static boolean updateRecords(List<Incident__c> editedAccounts) {
        system.debug(editedAccounts);
        try{
            update editedAccounts;
            return true;
        }
        catch(Exception e) {
            return false;
        }
    }
}

 
Hi All,

I have created 2 web-to-lead forms with 2 different site keys for hosting in different domains. The form(with reCaptcha)  hosted in domain 1 is generating the lead in salesforce after submitting the form. 

But, the form hosted in domain 2 is not generating any lead in salesforce even after properly validating all data. If I remove the reCaptcha part from the form and submit, its generating a lead in salesforce. But, with reCaptcha functionality included in the form, its not generating any lead in salesforce. I am not getting any error while submitting the form and I also enabled debug and it seems ok with all the correct inputs that I gave. 

Please Help!!!

Lokesh
Hello everyone,
I am trying to form a dynamic soql with multiple where clauses like below..
 
public class SearchClass {

@AuraEnabled
public static List<Object__c> searchWithInputs(String fromDate, String toDate, List<String> statuses...) {

     List<Object__c> records = new List<Object__c>();

     String query = 'Select Id,..... from Object__c where ';
     .
     .
     .
     .
     .
     .
     records = Database.query(query);

     return records;

}

Here, the method 'searchWithInputs' have multiple input parameters coming from a lightning component client controller. I need to generate the soql query in such a way it will handle different scenario like,
  • All input params are not null (no problem with with this one)
  • All input params are null (no problem with with this one)
  • Only some params are coming and rest are nulls. 
How do I form the query to make it dynamic so it will leave out the inputs which are nulls and consider only not nulls (actual inputs)?

Thanks
Hi All,

I have created 2 web-to-lead forms with 2 different site keys for hosting in different domains. The form(with reCaptcha)  hosted in domain 1 is generating the lead in salesforce after submitting the form. 

But, the form hosted in domain 2 is not generating any lead in salesforce even after properly validating all data. If I remove the reCaptcha part from the form and submit, its generating a lead in salesforce. But, with reCaptcha functionality included in the form, its not generating any lead in salesforce. I am not getting any error while submitting the form and I also enabled debug and it seems ok with all the correct inputs that I gave. 

Please Help!!!

Lokesh
Hi All,

I want to pass the record id from component to javascript controller on click on account name hyperlink.
 
<aura:iteration items="{!v.searchResult}" var="acc" indexVar="count">
                        <tr>
                            <td>
                                <div class="slds-truncate">{!count + 1}</div>
                            </td>
                            <td>
                                
                                <!--a href="{!'/one/one.app?#/sObject/'+ acc.Id + '/view'}" width="400" height="400" target="_blank"-->
                                <a onclick="{!c.openModel}">
                                    
                                	<div class="slds-truncate">{!acc.Name}</div>
                                </a>
                            </td>
                            <td>
                                <div class="slds-truncate">{!acc.PersonEmail}</div>
                            </td>
</tr>
</aura:iteration>

Please help me.

 
Hi,

I am trying to work out features of lightning dataTable and I am currently stuck at inline edit feature. I have created 2 components (both are independent) for 2 inline edit examples. 1st one is working as expected but the 2nd component is not working. 

Whenever I change some value in any row, it is suppossed to call Server controller. But my code never reaching server controller.. I am posting the entire code here. Please Help!!
Component
-------------------

<aura:component controller = "AdvancedORCASearchClass" 
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="searchData" type="Object" />
    <aura:attribute name="data" type="List" default="[]" />
    <aura:attribute name="columns" type="List" />
    <aura:attribute name="mySelectedRows" type="Object[]" />
    <aura:attribute name="selectedRowsCount" type="Integer" default="0" />
    <aura:attribute name="maxRowSelection" type="Integer" default="5"/>
    <aura:attribute name="isButtonEnabled" type="boolean" default="false" />
    
    <aura:attribute name="selectedIds" type="List" />
    
    <aura:attribute name="allData" type="List"/>
    <aura:attribute name="rowsToDisplay" type="Integer" default="7" />
    <aura:attribute name="totalPages" type="Integer" />
    <aura:attribute name="currentPageNumber" type="Integer" default="1"/>
    
    <aura:attribute name="enableInfiniteLoading" type="boolean" default="true" />
    <aura:attribute name="totalRows" type="Integer" />
    <aura:attribute name="offsetNumber" type="Integer" default="0" />
    <aura:attribute name="initialRows" type="Integer" default="7" />
    <aura:attribute name="isLoading" type="boolean" default="false" />
    <aura:attribute name="loadMoreStatus" type="String" default="" />
    
    
    <aura:attribute name="selection" type="List" access="PRIVATE"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <!-- <aura:handler event="c:AdvORCASendRecordId" action="{!c.refreshComponent}" />  -->
    <!--    <aura:handler event="force:refreshView" action="{!c.doInit}" /> -->
    
    <aura:method name="search" action="{!c.getSearchResult}">
        <aura:attribute name="fromDate" type="Date"/>
        <aura:attribute name="toDate" type="Date" />
        <aura:attribute name="selectedStatuses" type="String[]" />
        
    </aura:method>
    
    <lightning:navigation aura:id="navService" />
    
    <aura:if isTrue="{!v.isButtonEnabled}">
        <lightning:layout horizontalAlign="center">
            <lightning:layoutItem  padding="around-large">
                
                <lightning:button iconName="action:download" iconPosition="right" label="Download Selected" onclick="{!c.onDownload}" 
                                  variant="brand" />
                
            </lightning:layoutItem>
        </lightning:layout>
    </aura:if>
    
    <lightning:layout horizontalAlign="center" multipleRows="true">
        
        <lightning:layoutItem size="12">
            <div style="height: 300px">
                <lightning:dataTable  
                                     aura:id="dataTable"
                                     columns="{!v.columns}"
                                     data="{!v.data}"
                                     keyField="id"
                                     enableInfiniteLoading="{!v.enableInfiniteLoading}"
                                     onloadmore="{!c.loadMoreData}"
                                     isLoading="{!v.isLoading}"
                                     hideCheckboxColumns="false"
                                     onrowaction="{!c.handleRowAction}"
                                     maxRowSelection="{! v.maxRowSelection }"
                                     onrowselection="{! c.updateSelectedText }" 
                                     onsave="{! c.onSave}"
                                     />
            </div>
        </lightning:layoutItem>
        
        <aura:if isTrue="{!v.isButtonEnabled}">
            <lightning:layoutItem size="12" class="centerAlign">
                {!v.loadMoreStatus}
            </lightning:layoutItem>
            

    </lightning:layout>
    
</aura:component>
-----------------------------------------------------------------------------------------

Client Controller
---------------------------

({
    getSearchResult : function(component, event, helper) {
        component.set('v.data', []); 
        component.set('v.offsetNumber', 0);
        component.set('v.enableInfiniteLoading', true);
        //$A.get('e.force:refreshView').fire();
        var parameters = event.getParam('arguments');
        //alert('Data is set to [] here');
        if(parameters) {
            component.set('v.searchData', parameters); 
            
            //alert('Params are set here. To Helpers');
            
            helper.getTotalRows(component, event, helper);
            
            //alert('Helper1 is done');
            
            helper.getSearchResults(component, event, helper, component.get('v.offsetNumber'));
            //alert('Helper2 is done. Data size=='+component.get('v.data').length);
        }
    },
    
    /* refreshComponent : function(component, event, helper) {
        $A.get('e.force:refreshView').fire();
    }, */
    
    doInit : function(component, event, helper) {
        //component.set('v.data', []);
        //alert('length===='+component.get('v.data').length);
        
        var actions = [{label:"Change Status", name:"update_Status"},
                       {label:"Delete", name:"delete"}];        
        component.set('v.columns', [
            {label:"Incident Number", fieldName:"Name", type:"text"},
            {label:"View", type:"button", typeAttributes:{label:"View", name:"view_details", title:"Click here to View Details"}},
            {label:"Title", fieldName:"Title__c", type:"text", editable:true},
            {label:"Date", fieldName:"Incident_Date__c", type:"Date"},
            {label:"Risk Category", fieldName:"Risk_Category__c", type:"text"},
            {label:"Status", fieldName:"Status__c", type:"text"},
            {label:"Ops Risk Region", fieldName:"Ops_Risk_Region__c", type:"text"},
            {label:"Recorder", fieldName:"linkNameRec", type:"url", typeAttributes:{label:{fieldName:"Recorder__c"}, target:"_blank"}},
            {label:"Reviewer", fieldName:"linkNameRev", type:"url", typeAttributes:{label:{fieldName:"Reviewer__c"}, target:"_blank"}},
            {label:"Approver", fieldName:"linkNameApp", type:"url", typeAttributes:{label:{fieldName:"Approver__c"}, target:"_blank"}},
            {type:'action', typeAttributes:{rowActions:actions}}
        ]);
    },
    
    handleRowAction : function(component, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        switch (action.name) {
            case 'view_details':
                var navEvent = $A.get("e.force:navigateToSObject");
                if(navEvent) {
                    navEvent.setParams({
                        "recordId" : row.Id,
                        "slideDevName" : "detail"
                    });
                    window.open('/'+event.getParam('row').Id);
                }
                break;
                
            case 'delete':
                alert('Please dont delete me....');
                break;
                
            case 'update_Status':
                /*var appEvent = $A.get('e.c:AdvORCASendRecordId');
                appEvent.setParams({
                    "recordId":row.Id
                });
                alert('Before Firing');
                appEvent.fire();
                alert('After Firing'); */
                var navService = component.find('navService');
                var pageReference = {
                    "type":"standard__component", 
                    "attributes":{"componentName":"c__AdvancedORCAChangeStatus"},
                    "state":{recordId:row.Id}};
                navService.navigate(pageReference);
                //alert('KeyField:::'+row.keyField);
                
                break;
        }
    },
    
    onDownload : function(component, event, helper) {
        //alert('Selected Rows::'+component.get('v.mySelectedRows'));
        var stockData = component.get('v.mySelectedRows');
        
        if(stockData.length == 0) {
            alert('Please select at least one row to export results');
        }
        else {
            var csv = helper.convertArrayOfObjectsToCSV(component,stockData);
            
            if (csv == null){
                return;
            } 
            
            var hiddenElement = document.createElement('a');
            hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
            hiddenElement.target = '_self'; // 
            hiddenElement.download = 'ExportData.csv';  // CSV file Name* you can change it.[only name not .csv] 
            document.body.appendChild(hiddenElement); // Required for FireFox browser
            hiddenElement.click(); // using click() js function to download csv file
        }
        
    },
    
    updateSelectedText : function(component, event, helper) {
        //component.set('v.selectedIds', component.find('dataTable').get('v.keyField').Id);
        // alert('Selected IDs::'+component.get('v.selectedIds'));
        var selectedRows = event.getParam('selectedRows');
        component.set('v.mySelectedRows', selectedRows);
        
    },
   
    
    loadMoreData : function(component, event, helper) {
        //alert('Success untill here');
        //event.getSource().set("v.isLoading", true);
        component.set('v.isLoading', true);
        component.set('v.loadMoreStatus', 'Loading');
        component.set('v.offsetNumber', component.get('v.data').length);
        //alert('offset::'+component.get('v.offsetNumber'));
        helper.getSearchResults(component, event, helper, component.get('v.offsetNumber'));
    },
    
    onSave : function(component, event, helper) {
       // var editedRecords = component.find('dataTable').get('v.draftValues');
      //  alert('Number of records edited:'+editedRecords.length);
        helper.onEdit(component, event, helper);
    }
})
----------------------------------------------------------------------------------------------

Helper
--------------------
({
    getSearchResults : function(component, event, helper, offNumber) {
        //alert('Inside Helper');
        //alert('Offset Number::'+offNumber);
        var action1 = component.get('c.searchWithInputs');
        action1.setParams({
            fromDate:component.get('v.searchData').fromDate,
            toDate:component.get('v.searchData').toDate,
            statuses:component.get('v.searchData').selectedStatuses,
            rowsToDisplay:component.get('v.rowsToDisplay'),
            offsetNumber:offNumber
        });        
        action1.setCallback(this, function(response) {
            var state = response.getState();
            
            if(state==='SUCCESS') {
                //alert('Inside For');
                for(var i=0; i<response.getReturnValue().length; i++) {
                    // alert('Inside For');
                    var row = response.getReturnValue()[i];
                    
                    row.linkNameRec = "/"+row.Recorder__c;
                    row.Recorder__c = row.Recorder__r.Name;
                    
                    row.linkNameRev = "/"+row.Reviewer__c;
                    row.Reviewer__c = row.Reviewer__r.Name;
                    
                    row.linkNameApp = "/"+row.Approver__c;
                    row.Approver__c = row.Approver__r.Name;   
                }
                
                if(component.get('v.data').length >= component.get('v.totalRows')) {
                    component.set('v.enableInfiniteLoading', false);
                    component.set('v.loadMoreStatus', 'No more records to load.');
                }
                else {
                    var currentData = component.get('v.data');
                    var newData = currentData.concat(response.getReturnValue());
                    component.set('v.data', newData);
                    component.set('v.loadMoreStatus', '');   
                    //alert('Alert for length++++'+component.get('v.data').length);
                }
                component.set('v.isLoading', false);
                //event.getSource().set("v.isLoading", false);
                
                
                //component.set('v.totalPages', Math.ceil(response.getReturnValue().length/component.get('v.rowsToDisplay')));
                // component.set('v.data', response.getReturnValue());
                // component.set('v.currentPageNumber',1);
                
                if(component.get('v.isButtonEnabled') == false) {
                    component.set('v.isButtonEnabled', true);
                }
                
                
                //  helper.setData(component, event, helper);
            }
        });
        $A.enqueueAction(action1);
    },
    
    getTotalRows : function(component, event, helper) {
        var action2 = component.get('c.getCountIncidents');
        action2.setParams({
            fromDate:component.get('v.searchData').fromDate,
            toDate:component.get('v.searchData').toDate,
            statuses:component.get('v.searchData').selectedStatuses
            
        });    
        action2.setCallback(this, function(response) {
            var state = response.getState();
            
            if(state==='SUCCESS') {
                component.set('v.totalRows', response.getReturnValue().length);
            }
        });
        $A.enqueueAction(action2);
    },
    
    
    /* 
    setData : function(component, event, helper) {
        var data = [];
        var pageNumber = component.get('v.currentPageNumber');
        var totalPages = component.get('v.totalPages');
        var rowsToDisplay = component.get('v.rowsToDisplay');
        var allData = component.get('v.allData');
        
        var x = (pageNumber-1)*rowsToDisplay;
        
        for(;x<=(pageNumber)*(rowsToDisplay);x++) {
            if(allData[x]) {
                data.push(allData[x]);
            }
        }
        component.set('v.data', data);
    },
    */
    convertArrayOfObjectsToCSV : function(component, objectRecords) {
        var csvStringResult, counter, keys, columnDivider, lineDivider;
        if(objectRecords == null && !objectRecords.length) {
            return null;
        }
        columnDivider = ',';
        lineDivider = '\n';
        keys = ['Name', 'Title__c', 'Incident_Date__c', 'Risk_Category__c', 'Status__c', 'Ops_Risk_Region__c',
                'Recorder__c', 'Reviewer__c', 'Approver__c'];
        csvStringResult = '';
        csvStringResult += keys.join(columnDivider);
        csvStringResult += lineDivider;
        
        for(var i=0; i<objectRecords.length; i++) {
            counter = 0;
            for(var sTempkey in keys) {
                var skey = keys[sTempkey] ;  
                
                
                if(counter > 0){ 
                    csvStringResult += columnDivider; 
                }   
                
                csvStringResult += '"'+ objectRecords[i][skey]+'"'; 
                
                counter++;
                
            } 
            csvStringResult += lineDivider;
        }
        
        //alert('Returning thing:::'+csvStringResult);
        return csvStringResult; 
    },
    
    onEdit : function(component, event, helper) {
        var editedRecords = event.getParam('draftValues');
        var totalRecordEdited = editedRecords.length;
        
        var action = component.get("c.updateRecords");
        
        action.setParams({
            "editedAccounts" : editedRecords
        });
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === 'SUCCESS') {
                
                if(response.getReturnValue() === true) {
                    helper.showToast({
                        "title" : 'Record Update',
                        "type" : "success",
                        "message" : totalRecordEdited + " Records updated"
                    });
                    helper.reloadDataTable();
                }
                else {
                    helper.showToast({
                        "title": "Error!!",
                        "type": "error",
                        "message": "Error in update"
                    });
                }
            }
        });
        
        $A.enqueueAction(action);
    },
    
    showToast : function(params){
        var toastEvent = $A.get("e.force:showToast");
        if(toastEvent){
            toastEvent.setParams(params);
            toastEvent.fire();
        } else{
            alert(params.message);
        }
    },
    
    reloadDataTable : function(){
    var refreshEvent = $A.get("e.force:refreshView");
        if(refreshEvent){
            refreshEvent.fire();
        }
    },
    
})
---------------------------------------------------------------------------------------------------

Server Controller -- Apex Class
-----------------------------------------
public class AdvancedORCASearchClass {
    @AuraEnabled
    public static boolean updateRecords(List<Incident__c> editedAccounts) {
        system.debug(editedAccounts);
        try{
            update editedAccounts;
            return true;
        }
        catch(Exception e) {
            return false;
        }
    }
}

 
<lightning:input aura:id="startDate" type="date" name="startDate" label="Date" messageWhenValueMissing="You must specify Date" required="true" />

But it always showing message ="Complete this field." And If I change type="text" it works perfectly.
Hello everyone,
I am trying to form a dynamic soql with multiple where clauses like below..
 
public class SearchClass {

@AuraEnabled
public static List<Object__c> searchWithInputs(String fromDate, String toDate, List<String> statuses...) {

     List<Object__c> records = new List<Object__c>();

     String query = 'Select Id,..... from Object__c where ';
     .
     .
     .
     .
     .
     .
     records = Database.query(query);

     return records;

}

Here, the method 'searchWithInputs' have multiple input parameters coming from a lightning component client controller. I need to generate the soql query in such a way it will handle different scenario like,
  • All input params are not null (no problem with with this one)
  • All input params are null (no problem with with this one)
  • Only some params are coming and rest are nulls. 
How do I form the query to make it dynamic so it will leave out the inputs which are nulls and consider only not nulls (actual inputs)?

Thanks
Hi Folks,

I have set a custom error message using setCustomValidity() in lightning, while clearing it is not working for lightning:input date fields. Seems it is issue from Salesforce. Please let me know if there is any workaround.

Here is the example:
Lightning Component:
<aura:component implements="force:appHostable" >
    <lightning:card footer="Card Footer" title="Hello">
        <lightning:input Label="Name" aura:id="name" value="{!v.acc.Name}" required="true"/>
        <lightning:input type="date" aura:id="date" label="Enter a date" required="true" value="{!v.acc.dhr__Custom_Date_Time__c}"/>
        <lightning:input type="date" label="Enter a date" required="true" value="{!v.acc.dhr__SLA_Expiration_Date_Time__c}"/>
        
        <lightning:button variant="brand" label="Handle Form" title="Brand action" onclick="{! c.handleForm }" />
    </lightning:card>
</aura:component>


Javascript Controller:
({
	handleForm : function(component,event,helper){
        var nameCmp = component.find("name");
        if(!$A.util.isEmpty(component.get("v.acc.Name")) && component.get("v.acc.Name")=="Salesforce"){
        	nameCmp.setCustomValidity("Name cannot be Salesforce") ;
        }else{
            nameCmp.setCustomValidity("") ;
        }
        nameCmp.reportValidity() ;
        
        var dateCmp = component.find("date");
        if(component.get("v.acc.dhr__Custom_Date_Time__c") >   component.get("v.acc.dhr__SLA_Expiration_Date_Time__c")){
        	dateCmp.setCustomValidity("Cannot be future..") ;
        }else{
            alert('clearing..');
            dateCmp.setCustomValidity("") ;
        }
        dateCmp.reportValidity() ;
    }
})


Hello all,

I'm doing the "Build a Cat Rescue App That Recognizes Cat Breeds" module but I have issue with Install Einstein Vision Apex Wrappers step. Could you please help.
Thanks for your answers.

Challengre error
I am trying to use the new reCAPTCHA capability on a Web-to-Lead contact form that is being displayed on a Weebly website. I would like to enable my Submit button based on successful result form the reCAPTCHA. Right now, the user can still click the Submit even if they haven't check the reCAPTCHA checkbox. A lead isn't actually created, which is good, but it just goes on to my "Thank you" page, giving the user the impression they have submitted their contact  info. 

Here is the HTML at the end of my Web-to-Lead form that handles the reCAPTCHA. callValidation() is a function that checks to see whether the user has entered required fields in the form.
 
<div class="g-recaptcha" data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></div><br>
<div id="button">
  <input id="sell_house_submit" type="submit" name="submit" value="Get My Free Quote!" onclick="return callValidation();">
 </div>

I'm not an HTML/Javascript wizard. Can anyone help me?

TIA!