• Surinder Singh 51
  • NEWBIE
  • 20 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
Hello Guys,

Since I am new to Lightning and practicing myself by creating some simple components. 

I need some help to get some requirements simmilat to real time project requirements so that I try from my end.

Please share some sample requirments based on your project experience or if you know.
JS Controller :   method calling from Comp button.
 
createContact: function(component, event, helper){ //
         
         var createRecordEvent = $A.get('e.force:createRecord');
      
            createRecordEvent.setParams({
                'entityApiName': 'Contact',
                "defaultFieldValues": {
                    'Phone' : '415-240-6590'}
            });
            createRecordEvent.fire();
        
    }

Getting error : This page has an error. You might just need to refresh it. Action failed: c:getContactComp$controller$createContact [Cannot read property 'setParams' of undefined] Failing descriptor: {c:getContactComp$controller$createContact}



Requirmeent: on click of button, want to display create contact screen with default phone or any field.
Component: 

 <lightning:datatable style="width: 50%" data="{! v.ContactList }"
                             aura:id="accountDataTable"
                             columns="{! v.mycolumns }"

                             onrowselection="{!c.handleSelectedRow}"
                             keyField="Id"  onsave ="{!c.onSave}" hideCheckboxColumn="false" onrowaction="{!c.viewRecord }"
<lightning:button variant="Brand" label="Delete Selected Contacts" title="Success" onclick="{! c.handleSelectedRowdelete }"/> 

JS Controller :

handleSelectedRow: function(component, event, helper){
        var abc = event.getParam('selectedRows'); 
        
        var setRows =[];
        for(var i = 0;i<abc.length;i++ ) {
            alert('abc[i].id'+abc[i]);
            setRows.push(abc[i].id);
        } 
        
        component.set("v.selectedRows",setRows);
    },
    handleSelectedRowdelete: function(component, event, helper){
         var conList=component.get("v.selectedRows");
        alert(conList);
        var conIds =[];
        for(var i = 0;i<conList.length;i++ ) {
            
            conIds.push(conList[i].id);

        }
        alert("****Id****",conIds);
        
        var action = component.get("c.DeleteContactlist");
        action.setParams({
            'listcon' : conIds
        });
        action.setCallback(this,function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                //if update is successful
                component.set("v.showdelete",'True');
                component.set("v.ContactList",'');
                location.reload();
            }
        });
        $A.enqueueAction(action);


I want on click of Delete Selected Contacts , all selected contact should deleted. I have use onselected attribute of datatable and on selestion, I am updating selectedRows. On button click I am using SelectedRows and trying to get the id but getting error. 



Error:   Action failed: c:getContactComp$controller$handleSelectedRowdelete [Cannot read property 'id' of undefined]
Component: 

 <lightning:datatable style="width: 50%" data="{! v.ContactList }"
                             aura:id="accountDataTable"
                             columns="{! v.mycolumns }"

                             onrowselection="{!c.handleSelectedRow}"
                             keyField="Id"  onsave ="{!c.onSave}" hideCheckboxColumn="false" onrowaction="{!c.viewRecord }"
<lightning:button variant="Brand" label="Delete Selected Contacts" title="Success" onclick="{! c.handleSelectedRowdelete }"/> 

JS Controller :

handleSelectedRow: function(component, event, helper){
        var abc = event.getParam('selectedRows'); 
        
        var setRows =[];
        for(var i = 0;i<abc.length;i++ ) {
            alert('abc[i].id'+abc[i]);
            setRows.push(abc[i].id);
        } 
        
        component.set("v.selectedRows",setRows);
    },
    handleSelectedRowdelete: function(component, event, helper){
         var conList=component.get("v.selectedRows");
        alert(conList);
        var conIds =[];
        for(var i = 0;i<conList.length;i++ ) {
            
            conIds.push(conList[i].id);

        }
        alert("****Id****",conIds);
        
        var action = component.get("c.DeleteContactlist");
        action.setParams({
            'listcon' : conIds
        });
        action.setCallback(this,function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                //if update is successful
                component.set("v.showdelete",'True');
                component.set("v.ContactList",'');
                location.reload();
            }
        });
        $A.enqueueAction(action);


I want on click of Delete Selected Contacts , all selected contact should deleted. I have use onselected attribute of datatable and on selestion, I am updating selectedRows. On button click I am using SelectedRows and trying to get the id but getting error. 



Error:   Action failed: c:getContactComp$controller$handleSelectedRowdelete [Cannot read property 'id' of undefined]
Hello Guys,

Since I am new to Lightning and practicing myself by creating some simple components. 

I need some help to get some requirements simmilat to real time project requirements so that I try from my end.

Please share some sample requirments based on your project experience or if you know.
JS Controller :   method calling from Comp button.
 
createContact: function(component, event, helper){ //
         
         var createRecordEvent = $A.get('e.force:createRecord');
      
            createRecordEvent.setParams({
                'entityApiName': 'Contact',
                "defaultFieldValues": {
                    'Phone' : '415-240-6590'}
            });
            createRecordEvent.fire();
        
    }

Getting error : This page has an error. You might just need to refresh it. Action failed: c:getContactComp$controller$createContact [Cannot read property 'setParams' of undefined] Failing descriptor: {c:getContactComp$controller$createContact}



Requirmeent: on click of button, want to display create contact screen with default phone or any field.
Component: 

 <lightning:datatable style="width: 50%" data="{! v.ContactList }"
                             aura:id="accountDataTable"
                             columns="{! v.mycolumns }"

                             onrowselection="{!c.handleSelectedRow}"
                             keyField="Id"  onsave ="{!c.onSave}" hideCheckboxColumn="false" onrowaction="{!c.viewRecord }"
<lightning:button variant="Brand" label="Delete Selected Contacts" title="Success" onclick="{! c.handleSelectedRowdelete }"/> 

JS Controller :

handleSelectedRow: function(component, event, helper){
        var abc = event.getParam('selectedRows'); 
        
        var setRows =[];
        for(var i = 0;i<abc.length;i++ ) {
            alert('abc[i].id'+abc[i]);
            setRows.push(abc[i].id);
        } 
        
        component.set("v.selectedRows",setRows);
    },
    handleSelectedRowdelete: function(component, event, helper){
         var conList=component.get("v.selectedRows");
        alert(conList);
        var conIds =[];
        for(var i = 0;i<conList.length;i++ ) {
            
            conIds.push(conList[i].id);

        }
        alert("****Id****",conIds);
        
        var action = component.get("c.DeleteContactlist");
        action.setParams({
            'listcon' : conIds
        });
        action.setCallback(this,function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                //if update is successful
                component.set("v.showdelete",'True');
                component.set("v.ContactList",'');
                location.reload();
            }
        });
        $A.enqueueAction(action);


I want on click of Delete Selected Contacts , all selected contact should deleted. I have use onselected attribute of datatable and on selestion, I am updating selectedRows. On button click I am using SelectedRows and trying to get the id but getting error. 



Error:   Action failed: c:getContactComp$controller$handleSelectedRowdelete [Cannot read property 'id' of undefined]