• Madhusudan Singh 15
  • NEWBIE
  • 15 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 3
    Replies
Hi All,

I want to delete selected rows from datatable on a button click. How can I do that? Can anyone share a sample working code.

Regards
Madhusudan Singh
Hi Gurus,

I am using lightning datatable, and in that I am displaying a button in one column. Once a button is clicked of any record I want to change the lable of the button(Need toggle functionality).

Below is my codes

COMPONENT
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                controller='PaginationController'
                access="global" >
    
    <!-- Attribute Declration For Pagination -->
    <aura:attribute name="ContactData" type="Object"/>
    <aura:attribute name="columns" type="List"/>
    
     <aura:attribute name="isSending" type="boolean" />
    
    <!-- Attribute Declration For Pagination -->
    <aura:attribute name="PaginationList" type="Contact"/>
    <aura:attribute name="startPage" type="Integer" />
    <aura:attribute name="endPage" type="Integer"/>
    <aura:attribute name="totalRecords" type="Integer"/>
    <aura:attribute name="pageSize" type="Integer" default="10"/>
    <!-- Attribute Declration For Pagination End-->
    
    <aura:handler name="init" value="{! this }" action="{! c.doInit }"/>
    
    <!-- Spinner Start, show the loading screen while 
		 Client side controller(JS) is communicating with Server Side(APEX) controller -->
    <aura:if isTrue="{!v.isSending}">
        <div class="slds-spinner_container">
            <div class="slds-spinner--brand slds-spinner slds-spinner--large" role="alert">
                <span class="slds-assistive-text">Loading</span>
                <div class="slds-spinner__dot-a"></div>
                <div class="slds-spinner__dot-b"></div>
            </div>
        </div>
    </aura:if>
    <!-- Spinner End -->
    
    
    <div class="slds-m-top_medium" >
        <lightning:datatable data="{! v.PaginationList }"
                             columns="{! v.columns }" 
                             keyField="id"
                             onrowselection="{! c.getSelectedName }"
							 onrowaction="{! c.handleRowAction }"
                             hideCheckboxColumn="true"/>
        <br/>
        <lightning:buttonGroup >
            <lightning:button label="Previous" disabled="{!v.startPage == 0}"  
                              onclick="{!c.previous}" variant="brand"
                              iconName='utility:back'/>
            &nbsp; &nbsp; &nbsp;
            <lightning:button label="Next" disabled="{!v.endPage >= v.totalRecords}" 
                              onclick="{!c.next}" variant="brand"
                              iconName='utility:forward' iconPosition='right'/>
        </lightning:buttonGroup>
    </div>
</aura:component>

CONTROLLER
({
    doInit: function (component, event, helper) {
		// Set the columns of the Table 
        component.set('v.isSending',true);
        component.set('v.columns', [
            {label: 'Contact Name', fieldName: 'Name', type: 'text', sortable : false},
            {label: 'Email', fieldName: 'Email', type: 'email', sortable : false},
			{ type: 'button', typeAttributes: { iconName: 'utility:edit', label: 'Activate', name: 'activate', disabled: false}}
        ]);
            helper.doFetchContact(component);
    },
	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));
                break;
			case 'activate':
                alert('Edit Details: ' + action.label);
				console.log(cmp);
				var source = event.getSource();
				console.log(source);
				//source.set('label','New Label');
                break;
        }
    },
  getSelectedName: function (component, 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);
    }
   },
 next: function (component, event, helper) {
    helper.next(component, event);
},
    previous: function (component, event, helper) {
    helper.previous(component, event);
},
})

HELPER
({
    /*
     * Initially this Method will be called and will fetch the records from the Salesforce Org 
     * Then we will hold all the records into the attribute of Lightning Component
     */
	doFetchContact : function(component) {
		var action = component.get('c.showContacts');
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === 'SUCCESS' && component.isValid()){
                var pageSize = component.get("v.pageSize");
                // hold all the records into an attribute named "ContactData"
                component.set('v.ContactData', response.getReturnValue());
                // get size of all the records and then hold into an attribute "totalRecords"
                component.set("v.totalRecords", component.get("v.ContactData").length);
                // set star as 0
                component.set("v.startPage",0);
                
                component.set("v.endPage",pageSize-1);
                var PaginationList = [];
                for(var i=0; i< pageSize; i++){
                    if(component.get("v.ContactData").length> i)
                        PaginationList.push(response.getReturnValue()[i]);    
                }
                component.set('v.PaginationList', PaginationList);
                component.set('v.isSending',false);
            }else{
                alert('ERROR');
            }
        });
        $A.enqueueAction(action);
	},
    /*
     * Method will be called when use clicks on next button and performs the 
     * calculation to show the next set of records
     */
    next : function(component, event){
        var sObjectList = component.get("v.ContactData");
        var end = component.get("v.endPage");
        var start = component.get("v.startPage");
        var pageSize = component.get("v.pageSize");
        var Paginationlist = [];
        var counter = 0;
        for(var i=end+1; i<end+pageSize+1; i++){
            if(sObjectList.length > i){
                Paginationlist.push(sObjectList[i]);
            }
            counter ++ ;
        }
        start = start + counter;
        end = end + counter;
        component.set("v.startPage",start);
        component.set("v.endPage",end);
        component.set('v.PaginationList', Paginationlist);
    },
    /*
     * Method will be called when use clicks on previous button and performs the 
     * calculation to show the previous set of records
     */
    previous : function(component, event){
        var sObjectList = component.get("v.ContactData");
        var end = component.get("v.endPage");
        var start = component.get("v.startPage");
        var pageSize = component.get("v.pageSize");
        var Paginationlist = [];
        var counter = 0;
        for(var i= start-pageSize; i < start ; i++){
            if(i > -1){
                Paginationlist.push(sObjectList[i]);
                counter ++;
            }else{
                start++;
            }
        }
        start = start - counter;
        end = end - counter;
        component.set("v.startPage",start);
        component.set("v.endPage",end);
        component.set('v.PaginationList', Paginationlist);
    },
})

APEX CONTROLLER
public class PaginationController {
    @AuraEnabled
    public static List<Contact> showContacts(){
        List<Contact> contactList = new List<Contact>();
        contactList = [Select Id, Name, Title, Email, MobilePhone, Fax, AccountId From Contact LIMIT 100 ];
        return contactList;
    }
}

Please help me.
Hi All,

I am new to lightning and trying use file upload lightning components. 

I used exact same code which is mentioned in salesforce website
https://developer.salesforce.com/docs/component-library/bundle/lightning:fileUpload/example
just replaced recordid to my account id

But it is not working.

Please help me on this

Thanks in Advance
Hi All I am a newbie in SFDC and Apex. I am struggling with a silly thing from last night so seeking your help. 
I already gone through multiple Links of Maps and List but it is all giving just a basic Idea but not to what I am expecting
I want to create an data structure like below. I used PHP code to simplify the understanding

array(
    array(
    'CustomerID' => '12345',
    'CustomerName' = > 'Jhon',
    'CustomerRevenue' => 30000,
    ),
    array(
    'CustomerID' => '78927',
    'CustomerName' = > 'Martin',
    'CustomerRevenue' => 200000,
    ),
);

Question1: 
How to transform same values in Apex

Question2: 
How to retrieve Customer Revenue when list is finalized

Question3: How to loop over this to identify each record

Question4:
Now let say if I have another record for existing customer I want 'CustomerRevenue' to be SumUp


For Example another values that I need to add in existing array is Like this

array(
    'CustomerID' => '12345',
    'CustomerName' = > 'Jhon',
    'CustomerRevenue' => 50000,
),
    
Now my new array should be like

array(
    array(
    'CustomerID' => '12345',
    'CustomerName' = > 'Jhon',
    'CustomerRevenue' => 80000, // This value is changed
    ),
    array(
    'CustomerID' => '78927',
    'CustomerName' = > 'Martin',
    'CustomerRevenue' => 200000,
    ),
);

Regards
Madhusudan Singh
Hi All,

I am trying to parse below XML to get value of <state>RUNNING</state>. But it is giving null. I am using system.debug(document.getRootElement().getChildElement('return', null));

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header />
   <env:Body>
      <ns2:getOutboundCampaignResponse xmlns:ns2="http://service.admin.ws.five9.com/">
         <return>
            <description>1 - 14 Days Past Due</description>
            <mode>ADVANCED</mode>
            <name>Arrangements 1-14 TEST</name>
            <profileName>Arrangements</profileName>
            <state>RUNNING</state>
            <trainingMode>false</trainingMode>
            <type>OUTBOUND</type>
            <autoRecord>true</autoRecord>
            <callWrapup>
               <enabled>false</enabled>
            </callWrapup>
            <ftpHost />
            <ftpPassword />
            <ftpUser />
            <recordingNameAsSid>false</recordingNameAsSid>
            <useFtp>false</useFtp>
            <analyzeLevel>20</analyzeLevel>
            <CRMRedialTimeout>
               <days>0</days>
               <hours>1</hours>
               <minutes>0</minutes>
               <seconds>0</seconds>
            </CRMRedialTimeout>
            <dnisAsAni>false</dnisAsAni>
            <enableListDialingRatios>false</enableListDialingRatios>
            <listDialingMode>LIST_PENETRATION</listDialingMode>
            <noOutOfNumbersAlert>false</noOutOfNumbersAlert>
            <stateDialingRule>FOLLOW_STATE_RESTRICTIONS</stateDialingRule>
            <timeZoneAssignment>INHERIT_DOMAIN_SETTINGS</timeZoneAssignment>
            <actionOnAnswerMachine>
               <actionType>DROP_CALL</actionType>
            </actionOnAnswerMachine>
            <actionOnQueueExpiration>
               <actionType>DROP_CALL</actionType>
            </actionOnQueueExpiration>
            <callAnalysisMode>FAX_AND_ANSWERING_MACHINE</callAnalysisMode>
            <callsAgentRatio>1.0</callsAgentRatio>
            <dialNumberOnTimeout>true</dialNumberOnTimeout>
            <dialingMode>PROGRESSIVE</dialingMode>
            <dialingPriority>3</dialingPriority>
            <dialingRatio>50</dialingRatio>
            <distributionAlgorithm>MinHandleTime</distributionAlgorithm>
            <distributionTimeFrame>minutes30</distributionTimeFrame>
            <limitPreviewTime>true</limitPreviewTime>
            <maxDroppedCallsPercentage>3.0</maxDroppedCallsPercentage>
            <maxPreviewTime>
               <days>0</days>
               <hours>0</hours>
               <minutes>2</minutes>
               <seconds>0</seconds>
            </maxPreviewTime>
            <maxQueueTime>
               <days>0</days>
               <hours>0</hours>
               <minutes>0</minutes>
               <seconds>1</seconds>
            </maxQueueTime>
            <monitorDroppedCalls>true</monitorDroppedCalls>
            <previewDialImmediately>false</previewDialImmediately>
            <useTelemarketingMaxQueTimeEq1>false</useTelemarketingMaxQueTimeEq1>
         </return>
      </ns2:getOutboundCampaignResponse>
   </env:Body>
</env:Envelope>

Please help

Regards
Madhusudan Singh
Hi Folks,

I am trying to generate wsdl2apex for Five9 API but it ig giving error as 'Error: Failed to parse wsdl: Found schema import from location http://ws-i.org/profiles/basic/1.1/swaref.xsd. External schema import not supported'
https://www.dropbox.com/s/k577f06xc6yqjao/AdminWebService.xml?dl=0
I also tried to copying anf pasting the schema of http://ws-i.org/profiles/basic/1.1/swaref.xsd. With that I was able to parse wsdl but Apex class was not creating.

Need forum's help.

Thanks In Advance

Regards
Madhusudan Singh
Hi All,

I have created 3 Lightning Component Lets say

Component1
Component2
Component3

I am overriding New button of Lead Object and calling Component1.

From Component 1 I am navigating to Component 2 and from Component 2 to Component 3

My Problem is Once I navigate to Component 3 and abort my operation at Component 3 and next Time I click on New button it is directly Jumping to Component 3 with previous prefilled values. Ideally It should reinitate the process and Component 1 should load with blank fields.

Please help me in solving this issue.

Thanks in Advance.
Hi All,

I want to delete selected rows from datatable on a button click. How can I do that? Can anyone share a sample working code.

Regards
Madhusudan Singh
Hi All,

I am new to lightning and trying use file upload lightning components. 

I used exact same code which is mentioned in salesforce website
https://developer.salesforce.com/docs/component-library/bundle/lightning:fileUpload/example
just replaced recordid to my account id

But it is not working.

Please help me on this

Thanks in Advance
Hi Folks,

I am trying to generate wsdl2apex for Five9 API but it ig giving error as 'Error: Failed to parse wsdl: Found schema import from location http://ws-i.org/profiles/basic/1.1/swaref.xsd. External schema import not supported'
https://www.dropbox.com/s/k577f06xc6yqjao/AdminWebService.xml?dl=0
I also tried to copying anf pasting the schema of http://ws-i.org/profiles/basic/1.1/swaref.xsd. With that I was able to parse wsdl but Apex class was not creating.

Need forum's help.

Thanks In Advance

Regards
Madhusudan Singh