• sumit suwalka
  • SMARTIE
  • 505 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 256
    Questions
  • 244
    Replies
HI All,
      i have installed (Mass Edit + Mass Update + Mass Delete) app from app exchange.its working on Account,Contact and leads.
but its not working on case.
how can i make it to work on case?
or how can i mass update and edit on case?
Any suggestions?
Hi All,
i am trying to automate a lightning component . i write a script for it .
but i have a lookup field on it i dont know how to test it?
my script is given below:-
package myPackage;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class FamilyRecords {
    public static void main(String[] args) {
         // declaration and instantiation of objects/variables
        System.setProperty("webdriver.chrome.driver","C:\\Users\\user\\Downloads\\Chromedriver_win32\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        String baseUrl = "https://login.salesforce.com";
        driver.get(baseUrl);
        driver.findElement(By.id("username")).sendKeys("kmalek@fbgholdings.com.sfdcadmin");                        
        driver.findElement(By.id("password")).sendKeys("2&*ZMRrGFSx&");                        
        WebElement login = driver.findElement(By.id("Login"));
        login.submit();
        driver.navigate().to("https://fbg--sfdcadmin.lightning.force.com/lightning/r/Account/001S000000zb9KyIAI/view?0.source=alohaHeader");
        WebElement newpage = driver.findElement(By.cssSelector(".slds-button, .slds-button_neutral, .buttonStyle"));
        newpage.click(); 
        //driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
        driver.navigate().to("https://fbg--sfdcadmin.lightning.force.com/lightning/o/FBG_Family__c/new?nooverride=1&backgroundContext=%2Flightning%2Fr%2FAccount%2F001S000000zb9KyIAI%2Fview%3F0.source%3DalohaHeader&0.source=alohaHeader");
        System.out.println("click submit");
        WebDriverWait wait=new WebDriverWait(driver, 20);
        WebElement namefield = wait.until(
                ExpectedConditions.visibilityOfElementLocated(By.id("5998:0")));
        namefield.sendKeys("June12");
        WebElement namefield2 = wait.until(
                ExpectedConditions.visibilityOfElementLocated(By.id("6103:0")));
        namefield2.sendKeys("June12");
        WebElement Accsubmit = driver.findElement(By.cssSelector(".slds-button, .slds-button--neutral, .uiButton--brand, .uiButton, .forceActionButton"));

        Accsubmit.click();
        System.out.println("record submit");
        WebElement option1 =  driver.findElement(By.cssSelector(".slds-checkbox_faux"));                            
        //This will Toggle the Check box         
        option1.click();    
        driver.close();
        
    }
}User-added image
 
Hi All,
i am trying to create test class for following batch:-
public without sharing class BatchDeleteAndMergeDuplicateCases implements Database.Batchable<sObject> {
    
    public string subjectToFind ;
    public Set<Id> duplicateCaseIds;
    public Case parentCase;
 
    public BatchDeleteAndMergeDuplicateCases(Set<Id> duplicateCaseIds, Case parentCase){
        this.duplicateCaseIds = duplicateCaseIds;
        this.parentCase = parentCase;
    }
     public BatchDeleteAndMergeDuplicateCases(String subjectToFind, Set<Id> duplicateCaseIds, Case parentCase){
        this.subjectToFind = subjectToFind;
        this.duplicateCaseIds = duplicateCaseIds;
        this.parentCase = parentCase;
    }
     public static void run( Set<Id> CaseIds ) {
        Set<String> duplicateSubjectMetaData = new Set<String>();
        Set<String> duplicateEmailMetaData = new Set<String>();
        for(Duplicate_Merge_Rule_Exception__mdt duplicateMetaData : [SELECT Active__c, Subject__c 
                                                                     FROM Duplicate_Merge_Rule_Exception__mdt
                                                                     where Active__c =: True]){
            if(duplicateMetaData.Type__c == 'Email'){
               duplicateEmailMetaData.add(duplicateMetaData.Email__c);
            }else if(duplicateMetaData.Type__c == 'Subject'){                                                        
               duplicateSubjectMetaData.add(duplicateMetaData.Subject__c);
            }                                                                
        }
        List<Case> CaseRecords =  [Select id, Subject, 
                                   Origin, DuplicateOf__c,
                                   SuppliedEmail, Status,
                                   Duplicate_Count__c, CaseNumber,
                                   Description
                                   from case 
                                   where Id IN: CaseIds 
                                   AND origin != Null AND 
                                   origin =: 'Email' AND
                                   SuppliedEmail != Null AND 
                                   Subject != Null
                                   AND SuppliedEmail NOT IN: duplicateEmailMetaData 
                                   AND DuplicateOf__c =: Null
                                   ORDER By LastModifiedDate DESC];
        //executeHelper( CaseRecords , parentCase);                  
    }
     public Database.QueryLocator start(Database.BatchableContext BC){
        Set<String> duplicateSubjectMetaData = new Set<String>();
        Set<String> duplicateEmailMetaData = new Set<String>();
        for(Duplicate_Merge_Rule_Exception__mdt duplicateMetaData : [SELECT Active__c, Subject__c, Type__c, Email__c 
                                                                     FROM Duplicate_Merge_Rule_Exception__mdt
                                                                     where Active__c =: True]){
        
        
            if(duplicateMetaData.Type__c == 'Email'){
               duplicateEmailMetaData.add(duplicateMetaData.Email__c);
            }else if(duplicateMetaData.Type__c == 'Subject'){                                                        
                duplicateSubjectMetaData.add(duplicateMetaData.Subject__c);
            }                                                                
        }
         if(subjectToFind != Null && subjectToFind != ''){
            return Database.getQueryLocator([SELECT id, Subject, Origin,SuppliedEmail,
                                             Status, DuplicateOf__c, Description,
                                             Duplicate_Count__c, CaseNumber
                                             FROM Case
                                             WHERE Subject != null
                                             AND Subject LIKE: '%'+ subjectToFind + '%'
                                             AND Origin != Null
                                             And Origin = 'Email'
                                             AND SuppliedEmail != Null
                                             AND Subject NOT IN: duplicateSubjectMetaData
                                             AND SuppliedEmail NOT IN: duplicateEmailMetaData 
                                             AND DuplicateOf__c =: Null
                                             ORDER By CreatedDate DESC 
                                            ]);
            
            
        }
        else if(duplicateCaseIds != null && parentCase.Id != null ) {
            return Database.getQueryLocator([SELECT id, Subject, Origin,SuppliedEmail,
                                             Status, DuplicateOf__c, Description,
                                             Duplicate_Count__c, CaseNumber
                                             FROM Case
                                             WHERE Subject != null
                                             AND Origin != Null
                                             And Origin = 'Email'
                                             AND SuppliedEmail != Null
                                             AND Subject NOT IN: duplicateSubjectMetaData
                                             AND SuppliedEmail NOT IN: duplicateEmailMetaData 
                                             AND DuplicateOf__c =: Null
                                             AND Id in :duplicateCaseIds 
                                             ORDER By CreatedDate DESC 
                                            ]);
        }
        else {
             return Database.getQueryLocator([SELECT id, Subject, Origin,SuppliedEmail,
                                             Status, DuplicateOf__c, Description,
                                             Duplicate_Count__c, CaseNumber
                                             FROM Case
                                             WHERE Subject != null
                                             AND Origin != Null
                                             And Origin = 'Email'
                                             AND SuppliedEmail != Null
                                             AND Subject NOT IN: duplicateSubjectMetaData
                                             AND SuppliedEmail NOT IN: duplicateEmailMetaData 
                                             AND DuplicateOf__c =: Null
                                             ORDER By CreatedDate DESC 
                                            ]);
        } 
    }
     public void execute(Database.BatchableContext BC, List<Case> cases){
        executeHelper(cases, parentCase);
    }
    
    public void finish(Database.BatchableContext BC){
        
    }
     public static void executeHelper(List<Case> caseRecords, Case parentCase){
        
        EmailMessageTriggerHelper.runTrigger = False;
        CaseTriggerHelper.runTrigger = False;
        
        List<EmailMessage> emList = new List<EmailMessage>();
        
        String objectName = 'EmailMessage';  // modify as needed
        String soql = getCreatableFieldsSOQL('EmailMessage', 'ParentId IN :caseRecords');
        emList = database.query(soql);
        
        List<EmailMessage> emListToInsert = new List<EmailMessage>();
        if(emList.size() > 0){
           for(EmailMessage em : emList){
              EmailMessage emToInsert = em.clone(False); 
              emToInsert.ParentId = parentCase.Id; 
               emToInsert.CreatedDate = em.CreatedDate;
               emToInsert.LastModifiedDate = em.LastModifiedDate;
               emToInsert.CreatedById = em.CreatedById;
               emToInsert.LastModifiedById = em.LastModifiedById;
               emListToInsert.add(emToInsert);
           } 
        }
         if(emListToInsert.size() > 0){
            insert emListToInsert;
            
            // merge log
            List<Merge_Log__c> mlList = new List<Merge_Log__c>();
            Set<Id> deleteCaseIds = new Set<Id>();
            for(Case caseObj : caseRecords){
                Merge_Log__c ml = new Merge_Log__c();
                ml.Case__c = caseObj.Id;
                ml.MergedWith__c = caseObj.DuplicateOf__c;
                ml.Case_Details__c = JSON.serializePretty(caseObj);
                ml.Merge_Details__c = '';
                mlList.add(ml);
            }
            if(mlList.size() > 0){
                insert mlList;
            }
             //delete duplicate cases
            delete caseRecords; 
        }
     }
    
    // Returns a dynamic SOQL statement for the whole object, includes only creatable fields since we will be inserting a cloned result of this query
    public static string getCreatableFieldsSOQL(String objectName, String whereClause){
         
        String selects = '';
         
        if (whereClause == null || whereClause == ''){ return null; }
         
        // Get a map of field name and field token
        Map<String, Schema.SObjectField> fMap = Schema.getGlobalDescribe().get(objectName.toLowerCase()).getDescribe().Fields.getMap();
        list<string> selectFields = new list<string>();
         
        if (fMap != null){
            for (Schema.SObjectField ft : fMap.values()){ // loop through all field tokens (ft)
                Schema.DescribeFieldResult fd = ft.getDescribe(); // describe each field (fd)
                if (fd.isCreateable() && fd.getName() != 'ValidatedFromAddress'){ // field is creatable
                    selectFields.add(fd.getName());
                }
            }
        }
         
        if (!selectFields.isEmpty()){
            for (string s:selectFields){
                selects += s + ',';
            }
            if (selects.endsWith(',')){selects = selects.substring(0,selects.lastIndexOf(','));}
             
        }
         
        return 'SELECT ' + selects + ' FROM ' + objectName + ' WHERE ' + whereClause;
         
    }
     
}
how to create the test class for it?
Any suggestions?
Hi All,
i have a lightning component in which i am taking records of a custom object .here when i click on checkbox the record is removed.
but after reloading the page its coming again in data table i want that in this records  i have a Checkbox field (False_Positive__c). this field become true for the record. so that the record does not show again on data table.
how to do it?
Any suggestions?
my component and controller is given below:-
<aura:component controller="FBGFamilyController"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <!--aura:attribute name="PageHeading" type="String" default="Remove  False positive On Click Of Check Box" /-->
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:handler name="init" value="{!this}" action="{!c.doinit}" />
    
    
    <div class="slds-section slds-is-open">
        <h3 class="slds-section__title slds-theme_shade">
            <span class="slds-truncate slds-p-horizontal_small" title="Section Title">Family Records</span>
            <lightning:layoutItem class="right-align">
                <lightning:button label="New" onclick="{!c.createRecord}" class="buttonStyle"/>
            </lightning:layoutItem> 
        </h3>
        <lightning:datatable data="{! v.mydata }" 
                             columns="{! v.mycolumns }" 
                             keyField="Id" 
                             onrowselection="{! c.removeRow }"
                             hideCheckboxColumn="false"
                             />
        
    </div>
</aura:component>
Controller is given below:-
({
    doinit : function(component, event, helper) {
        component.set('v.mycolumns', [
            
            {label: 'Name', fieldName: 'linkName', type: 'url', 
             typeAttributes: {label: { fieldName: 'Name' }, target: '_blank'}},
            /*{label: 'Sister Account ', fieldName: 's1', type: 'url', 
             typeAttributes: {label: { fieldName: 'Sister_Company__r.Name' }, target: '_blank'}},
            {label: 'Sister Account ', fieldName: 's2', type: 'url', 
             typeAttributes: {label: { fieldName: ' Sister_Company2__r.Name' }, target: '_blank'}}*/
            {label: 'Division', fieldName: 'd1', type: 'text'},
            {label: 'Sister Account', fieldName: 's1', type: 'text'},
            {label: 'Sister Account', fieldName: 's2', type: 'text'},
            {label: 'State', fieldName: 'State__c', type: 'text'},
            {label: 'Type', fieldName: 'Type__c', type: 'text'},
            {label: 'Owner', fieldName: 'Oid', type: 'text'}
        ]);
        
        var action = component.get('c.fetchRecords');
        var recordId =  component.get("v.recordId");
        action.setParams({rid : recordId});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var allValues = response.getReturnValue();
                
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s1 = row.Sister_Company__r.Name;
                }
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s2 = row.Sister_Company2__r.Name;
                }
                 for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.d1 = row.Sister_Company__r.RecordType.Name;
                }
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.Oid = row.Owner.Name;
                }
                 
                allValues.forEach(function(record){
                    record.linkName = '/'+record.Id;
                });
                /* allValues.forEach(function(record){
                     record.s1 = '/'+record.Sister_Company__r.Id;
                }); 
                 allValues.forEach(function(record){
                    record.s2 = '/'+record.Sister_Company2__r.Id;
                }); */
                console.log("allValues--->>> " + allValues);
                component.set('v.mydata', allValues);
            }
            else if(state === "ERROR") {
                var errors = response.getError();
                if(errors){
                    if(errors[0] && errors[0].message){
                        console.log("Error Message: " + errors[0].message);
                    }
                }
                else{
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    removeRow : function(component, event, helper){
        var selRows = event.getParam('selectedRows');
        
        // Remove the record from the table
        var rows = component.get('v.mydata');
        for (var i = 0; i<selRows.length; i++){    
            var rowIndex = rows.indexOf(selRows[i]);
            console.log('rowIndex---->>> ' + rowIndex);
            var r=rows.splice(rowIndex, 1);   
            
            console.log('rrr---->>> ' + JSON.stringify(r));
            component.set('v.mydata', rows);
        }
    },
    
     createRecord : function (component, event, helper) {
        var createRecordEvent = $A.get("e.force:createRecord");
        createRecordEvent.setParams({
            "entityApiName": "FBG_Family__c"
        });
        createRecordEvent.fire();
    }
    
})
my Apex class is given below:-
public class FBGFamilyController {
        @AuraEnabled
    public static List<FBG_Family__c> fetchRecords(String rid) {
        return [SELECT Id, Name, Owner.Name,Type__c, Sister_Company__r.RecordType.Name, False_Positive__c,
                State__c, Division1__c, Sister_Company__r.Name, Sister_Company2__r.Name 
                FROM FBG_Family__c
                WHERE Sister_Company__c =: rid 
                AND False_Positive__c = FALSE
                ORDER BY Name  ASC ];
    }
}
i want when i click on Checkbox on data table a CheckBox field become False_Positive__c become true for that record.
how to do it?
Any suggestions?
Hi All,
i have a lightning component in which i am taking records of a custom object .here when i click on checkbox the record is removed.
but after reloading the page its coming again in data table i want that this records does not show again in data table.i dont want to delete the record.
how to do it?
Any suggestions?
my component and controller is given below:-
<aura:component controller="FBGFamilyController"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <!--aura:attribute name="PageHeading" type="String" default="Remove  False positive On Click Of Check Box" /-->
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:handler name="init" value="{!this}" action="{!c.doinit}" />
    
    
    <div class="slds-section slds-is-open">
        <h3 class="slds-section__title slds-theme_shade">
            <span class="slds-truncate slds-p-horizontal_small" title="Section Title">Family Records</span>
            <lightning:layoutItem class="right-align">
                <lightning:button label="New" onclick="{!c.createRecord}" class="buttonStyle"/>
            </lightning:layoutItem> 
        </h3>
        <lightning:datatable data="{! v.mydata }" 
                             columns="{! v.mycolumns }" 
                             keyField="Id" 
                             onrowselection="{! c.removeRow }"
                             hideCheckboxColumn="false"
                             />
        
    </div>
</aura:component>
Controller is given below:-
({
    doinit : function(component, event, helper) {
        component.set('v.mycolumns', [
            
            {label: 'Name', fieldName: 'linkName', type: 'url', 
             typeAttributes: {label: { fieldName: 'Name' }, target: '_blank'}},
            /*{label: 'Sister Account ', fieldName: 's1', type: 'url', 
             typeAttributes: {label: { fieldName: 'Sister_Company__r.Name' }, target: '_blank'}},
            {label: 'Sister Account ', fieldName: 's2', type: 'url', 
             typeAttributes: {label: { fieldName: ' Sister_Company2__r.Name' }, target: '_blank'}}*/
            {label: 'Division', fieldName: 'd1', type: 'text'},
            {label: 'Sister Account', fieldName: 's1', type: 'text'},
            {label: 'Sister Account', fieldName: 's2', type: 'text'},
            {label: 'State', fieldName: 'State__c', type: 'text'},
            {label: 'Type', fieldName: 'Type__c', type: 'text'},
            {label: 'Owner', fieldName: 'Oid', type: 'text'}
        ]);
        
        var action = component.get('c.fetchRecords');
        var recordId =  component.get("v.recordId");
        action.setParams({rid : recordId});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var allValues = response.getReturnValue();
                
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s1 = row.Sister_Company__r.Name;
                }
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s2 = row.Sister_Company2__r.Name;
                }
                 for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.d1 = row.Sister_Company__r.RecordType.Name;
                }
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.Oid = row.Owner.Name;
                }
                 
                allValues.forEach(function(record){
                    record.linkName = '/'+record.Id;
                });
                /* allValues.forEach(function(record){
                     record.s1 = '/'+record.Sister_Company__r.Id;
                }); 
                 allValues.forEach(function(record){
                    record.s2 = '/'+record.Sister_Company2__r.Id;
                }); */
                console.log("allValues--->>> " + allValues);
                component.set('v.mydata', allValues);
            }
            else if(state === "ERROR") {
                var errors = response.getError();
                if(errors){
                    if(errors[0] && errors[0].message){
                        console.log("Error Message: " + errors[0].message);
                    }
                }
                else{
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    removeRow : function(component, event, helper){
        var selRows = event.getParam('selectedRows');
        
        // Remove the record from the table
        var rows = component.get('v.mydata');
        for (var i = 0; i<selRows.length; i++){    
            var rowIndex = rows.indexOf(selRows[i]);
            console.log('rowIndex---->>> ' + rowIndex);
            var r=rows.splice(rowIndex, 1);   
            
            console.log('rrr---->>> ' + JSON.stringify(r));
            component.set('v.mydata', rows);
        }
    },
    
     createRecord : function (component, event, helper) {
        var createRecordEvent = $A.get("e.force:createRecord");
        createRecordEvent.setParams({
            "entityApiName": "FBG_Family__c"
        });
        createRecordEvent.fire();
    }
    
})
Hi All,
i have created a lightning component having lightning data table in which i am showing fields of custom object.
I have a formula field called Division having image, i want to show this in data table but its giving me only image source.like this:-<img src="/servlet/servlet.FileDownload?file=01541000001xSd8" alt=" " border="0"/>
i want to show image on it.
here is my component showing fields of custom objectUser-added imagei want to show image on it.
my controller is given below:-
({
    doinit : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Name', fieldName: 'linkName', type: 'url', 
             typeAttributes: {label: { fieldName: 'Name' }, target: '_blank'}},
             {label: 'Division', fieldName: 'Division1__c', type: 'image'}, //here its showing only source
            {label: 'Sister Account', fieldName: 's1', type: 'text'},
            {label: 'Sister Account', fieldName: 's2', type: 'text'},
            {label: 'State', fieldName: 'State__c', type: 'text'},
            {label: 'Type', fieldName: 'Type__c', type: 'text'},
            {label: 'Owner', fieldName: 'Oid', type: 'text'}
        ]);
        
        var action = component.get('c.fetchRecords');
        var recordId =  component.get("v.recordId");
        action.setParams({rid : recordId});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var allValues = response.getReturnValue();
                
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s1 = row.Sister_Company__r.Name;
                }
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s2 = row.Sister_Company2__r.Name;
                }
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.Oid = row.Owner.Name;
                }
                 
                allValues.forEach(function(record){
                    record.linkName = '/'+record.Id;
                });
                 console.log("allValues--->>> " + allValues);
                component.set('v.mydata', allValues);
            }
            else if(state === "ERROR") {
                var errors = response.getError();
                if(errors){
                    if(errors[0] && errors[0].message){
                        console.log("Error Message: " + errors[0].message);
                    }
                }
                else{
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    removeRow : function(component, event, helper){
        var selRows = event.getParam('selectedRows');
        
        // Remove the record from the table
        var rows = component.get('v.mydata');
        for (var i = 0; i<selRows.length; i++){    
            var rowIndex = rows.indexOf(selRows[i]);
            console.log('rowIndex---->>> ' + rowIndex);
            var r=rows.splice(rowIndex, 1);   
            
            console.log('rrr---->>> ' + JSON.stringify(r));
            component.set('v.mydata', rows);
        }
    },
 
})
how to get image in the field?
what am i missing?
Anu suggestions?
Hi All,
         i am trying to make the lookup field a hyper link which show the Account clicking on it.
my controller  is given below:-
 ({

    doinit : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Record Number ', fieldName: 'linkName', type: 'url', 
             typeAttributes: {label: { fieldName: 'Name' }, target: '_blank'}},
            {label: 'Sister Account ', fieldName: 's1', type: 'url', 
             typeAttributes: {label: { fieldName: 'Sister_Company__c' },value:{fieldName: 'Sister_Company__c.Id'}, target: '_blank'}},
            {label: 'Sister Account ', fieldName: 's2', type: 'url', 
             typeAttributes: {label: { fieldName: ' Sister_Company2__c' },value:{fieldName: 's2'}, target: '_blank'}}

          
        ]);
        
        var action = component.get('c.fetchRecords');
        var recordId =  component.get("v.recordId");
        action.setParams({rid : recordId});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var allValues = response.getReturnValue();
            
                  allValues.forEach(function(record){
                    record.linkName = '/'+record.Id;
                });
               allValues.forEach(function(record){
                    record.s1 = '/'+record.Sister_Company__r.Name;
                }); 
                 allValues.forEach(function(record){
                    record.s2 = '/'+record.Sister_Company2__r.Id;

                }); 
                console.log("allValues--->>> " + allValues);
                component.set('v.mydata', allValues);
            }
            else if(state === "ERROR") {
                var errors = response.getError();
                if(errors){
                    if(errors[0] && errors[0].message){
                        console.log("Error Message: " + errors[0].message);
                    }
                }
                else{
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    removeRow : function(component, event, helper){
        var selRows = event.getParam('selectedRows');
        
        // Remove the record from the table
        var rows = component.get('v.mydata');
        for (var i = 0; i<selRows.length; i++){    
            var rowIndex = rows.indexOf(selRows[i]);
            console.log('rowIndex---->>> ' + rowIndex);
            var r=rows.splice(rowIndex, 1);   
            
            console.log('rrr---->>> ' + JSON.stringify(r));
            component.set('v.mydata', rows);
         }
    }
 })     
                here the name is working as hyper link but on lookup i am getting ids as hyperlink not their name.
                i want lookup field (Sister_Company__c's name as hyper link.
                how to do it?
                Any suggestions?
Hi All,
 i created a ligtning component in which i am showing records of custom object having lookup of account.
i want that it should show only those custom object records which are related to that particular account in which related list  i am using it.
how to do it?
Any suggestions?
My component and controller is given below:-
<aura:component controller="FBGFamilyController"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <aura:attribute name="PageHeading" type="String" default="Remove  False positive On Click Of Check Box" />
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>

    
    <aura:handler name="init" value="{!this}" action="{!c.doinit}" />
    
    <div class="slds-m-top--xx-large">
        <div class="slds-page-header">
            <div class="slds-align--absolute-center">
                <div class="slds-text-heading--large">       
                    {!v.PageHeading}
                </div>
            </div>
        </div>
    </div>
    
 

    
    <div class="slds-section slds-is-open">
        <h3 class="slds-section__title slds-theme_shade">
              <span class="slds-truncate slds-p-horizontal_small" title="Section Title">Family Records</span>
          </h3>
        

        <lightning:datatable data="{! v.mydata }" 
                             columns="{! v.mycolumns }" 
                             keyField="Id" 
                             onrowselection="{! c.removeRow }"
                           />
    </div>
</aura:component>
**********************************
controller is given below:-
({
    doinit : function(component, event, helper) {
        component.set('v.mycolumns', [
           
            {label: 'Record Number', fieldName: 'Name', type: 'integer'},
            
            {label: 'Sister Account', fieldName: 's1', type: 'text'},
            {label: 'Sister Account', fieldName: 's2', type: 'text'}

        ]);
        
        var action = component.get('c.fetchRecords');
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var allValues = response.getReturnValue();
                 for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s1 = row.Sister_Company__r.Name;
                }
                 for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s2 = row.Sister_Company2__r.Name;
                }
                console.log("allValues--->>> " + allValues);
                component.set('v.mydata', allValues);
            }
            else if(state === "ERROR") {
                var errors = response.getError();
                if(errors){
                    if(errors[0] && errors[0].message){
                        console.log("Error Message: " + errors[0].message);
                    }
                }
                else{
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    removeRow : function(component, event, helper){
        var selRows = event.getParam('selectedRows');
        
        // Remove the record from the table
        var rows = component.get('v.mydata');
        for (var i = 0; i<selRows.length; i++){    
            var rowIndex = rows.indexOf(selRows[i]);
            console.log('rowIndex---->>> ' + rowIndex);
            var r=rows.splice(rowIndex, 1);   
            console.log('rrr---->>> ' + JSON.stringify(r));
            component.set('v.mydata', rows);
        }
    }
})
******************************************************
public class FBGFamilyController {
        @AuraEnabled
    public static List<FBG_Family__c> fetchRecords() {
        return [SELECT Id, Name, Sister_Company__r.Name, Sister_Company2__r.Name FROM FBG_Family__c];
    }
}
 HI All,
 i created a lightning component in which i am using lightning data table and showing records of custom object.
 my component and controller is given below:-
 <aura:component controller="FBGFamilyController"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <aura:attribute name="PageHeading" type="String" default="Remove  False positive On Click Of Check Box" />
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>

    
    <aura:handler name="init" value="{!this}" action="{!c.doinit}" />
    
    <div class="slds-m-top--xx-large">
        <div class="slds-page-header">
            <div class="slds-align--absolute-center">
                <div class="slds-text-heading--large">       
                    {!v.PageHeading}
                </div>
            </div>
        </div>
    </div>
    
 

    
    <div class="slds-section slds-is-open">
        <h3 class="slds-section__title slds-theme_shade">
              <span class="slds-truncate slds-p-horizontal_small" title="Section Title">Family Records</span>
          </h3>
        

        <lightning:datatable data="{! v.mydata }" 
                             columns="{! v.mycolumns }" 
                             keyField="Id" 
                             onrowselection="{! c.removeRow }"
                           />
    </div>
</aura:component>
**********************************
Controller:-
controller is given below:-
({
    doinit : function(component, event, helper) {
        component.set('v.mycolumns', [
           
            {label: 'Record Number', fieldName: 'Name', type: 'integer'},
            
            {label: 'Sister Account', fieldName: 's1', type: 'text'},
            {label: 'Sister Account', fieldName: 's2', type: 'text'}

        ]);
        
        var action = component.get('c.fetchRecords');
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var allValues = response.getReturnValue();
                 for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s1 = row.Sister_Company__r.Name;
                }
                 for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s2 = row.Sister_Company2__r.Name;
                }
                console.log("allValues--->>> " + allValues);
                component.set('v.mydata', allValues);
            }
            else if(state === "ERROR") {
                var errors = response.getError();
                if(errors){
                    if(errors[0] && errors[0].message){
                        console.log("Error Message: " + errors[0].message);
                    }
                }
                else{
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    removeRow : function(component, event, helper){
        var selRows = event.getParam('selectedRows');
        
        // Remove the record from the table
        var rows = component.get('v.mydata');
        for (var i = 0; i<selRows.length; i++){    
            var rowIndex = rows.indexOf(selRows[i]);
            console.log('rowIndex---->>> ' + rowIndex);
            var r=rows.splice(rowIndex, 1);   
            console.log('rrr---->>> ' + JSON.stringify(r));
            component.set('v.mydata', rows);
        }
    }
})
right now its looking like this:-User-added image

i want that it should look like this standard related list given below:-
User-added imagehow can i modify my code to achive this?
Any suggestions?
 
Hi All,
       i have a trigger in which i am inserting reverse records.i have imple mented the trigger its working fine for insertion . now i want that if i update or delete a record its reverse record should also get updated or deleted.
       my trigger is given below:-
       trigger Trigger_FBGFamily on FBG_Family__c (before insert, before update, 
                                            before delete, after insert, 
                                            after update, after delete) {
                                                
    FBGFamilyTriggerHelper.newFBGFamily = trigger.new;
    FBGFamilyTriggerHelper.oldFBGFamily = trigger.old;
    FBGFamilyTriggerHelper.newMapFBGFamily = trigger.newMap;
    FBGFamilyTriggerHelper.oldMapFBGFamily = trigger.oldMap;   
                                                
       if(!FBGFamilyTriggerHelper.runTrigger) {
        return;
    }
                                                if( Trigger.isAfter ){
                                                    if(Trigger.isInsert ){
                                                        FBGFamilyTriggerHelper.CreatingReverseFamilyRecords();   
                                                    }
                                                    
                                                }
                                                 if( Trigger.isBefore ){
                                                    if(Trigger.isDelete ){
                                                        FBGFamilyTriggerHelper.deletingReverseFamilyRecords();   
                                                    }
                                                    
                                                }
                                            }
        my helper class is given below:-
        public class FBGFamilyTriggerHelper {
    public static List<FBG_Family__c> newFBGFamily = new List<FBG_Family__c>();
    public static List<FBG_Family__c> oldFBGFamily = new List<FBG_Family__c>();
    public static Map<Id, FBG_Family__c> newMapFBGFamily = new Map<Id, FBG_Family__c>();
    public static Map<Id, FBG_Family__c> oldMapFBGFamily = new Map<Id, FBG_Family__c>();
    
        public static boolean runTrigger = TRUE;
    
     Public static void CreatingReverseFamilyRecords(){
        System.debug('processed'+newFBGFamily);
        List<FBG_Family__c> ListFamilyToInsert = New List<FBG_Family__c>();
         For(FBG_Family__c Family : newFBGFamily)
        {
            FBG_Family__c ReverseFamily = New FBG_Family__c();
            ReverseFamily.Sister_Company__c = Family.Sister_Company2__c;
            ReverseFamily.Sister_Company2__c = Family.Sister_Company__c;
            ListFamilyToInsert.Add(ReverseFamily);
            System.debug('ReverseFamily'+ListFamilyToInsert);

         }
        if(ListFamilyToInsert.Size() > 0){
            runTrigger = FALSE;
          Insert ListFamilyToInsert;
            runTrigger = TRUE;
           System.debug('ReverseFamily'+ListFamilyToInsert);

         }
    }
    public static void deletingReverseFamilyRecords(){
         //To store Family ids
    list<id> Famids = new list<id>();
    for(FBG_Family__c Family : oldFBGFamily)
    {
        system.debug('old list'+oldFBGFamily);
        Famids.add(Family.id);
    }  
    system.debug('Famids'+Famids);

    //Collecting all records related to Family records
        list<FBG_Family__c> listOfFamilyToDelete = [SELECT id  
                                                    FROM FBG_Family__c 
                                                    WHERE ID IN : Famids
                                                   ];
    system.debug('listOfFamily'+listOfFamilyToDelete);
    //deleting Reverse records
     if(listOfFamilyToDelete.Size() > 0){
     delete listOfFamilyToDelete;
      }  
    }
}
its not working for deletion.
Any suggestion? how to solve it?
Hi All,
         i have a requirement in which i created a trigger when a record is created. i am creating reverse records of same object. now i want that if record is updated or deleted it should update and delete the reverse record too.
my trigger and helper is given below:-
trigger Trigger_FBGFamily on FBG_Family__c (before insert, before update, 
                                            before delete, after insert, 
                                            after update, after delete) {
                                                
    FBGFamilyTriggerHelper.newFBGFamily = trigger.new;
    FBGFamilyTriggerHelper.oldFBGFamily = trigger.old;
    FBGFamilyTriggerHelper.newMapFBGFamily = trigger.newMap;
    FBGFamilyTriggerHelper.oldMapFBGFamily = trigger.oldMap;   
                                                
       if(!FBGFamilyTriggerHelper.runTrigger) {
        return;
    }
                                                if( Trigger.isAfter ){
                                                    if(Trigger.isInsert ){
                                                        FBGFamilyTriggerHelper.CreatingReverseFamilyRecords();   
                                                    }
                                                    
                                                }
                                            }
my helper is given below:-
public class FBGFamilyTriggerHelper {
    public static List<FBG_Family__c> newFBGFamily = new List<FBG_Family__c>();
    public static List<FBG_Family__c> oldFBGFamily = new List<FBG_Family__c>();
    public static Map<Id, FBG_Family__c> newMapFBGFamily = new Map<Id, FBG_Family__c>();
    public static Map<Id, FBG_Family__c> oldMapFBGFamily = new Map<Id, FBG_Family__c>();
    
        public static boolean runTrigger = TRUE;
    
     Public static void CreatingReverseFamilyRecords(){
        System.debug('processed'+newFBGFamily);
        List<FBG_Family__c> ListFamilyToInsert = New List<FBG_Family__c>();
         For(FBG_Family__c Family : newFBGFamily)
        {
            FBG_Family__c ReverseFamily = New FBG_Family__c();
            ReverseFamily.Sister_Company__c = Family.Sister_Company2__c;
            ReverseFamily.Sister_Company2__c = Family.Sister_Company__c;
            ListFamilyToInsert.Add(ReverseFamily);
            System.debug('ReverseFamily'+ListFamilyToInsert);

         }
        if(ListFamilyToInsert.Size() > 0){
            runTrigger = FALSE;
          Insert ListFamilyToInsert;
            runTrigger = TRUE;
           System.debug('ReverseFamily'+ListFamilyToInsert);

         }
    }
}
how to do it ? any suggestions?
Hi All,
 i created the batch given below:-
 //Batch to create FBGFamily junction records for Account having same name
public class BatchFBGFamilies implements Database.Batchable<sObject> {
    //run method to execute batch on one record
    public static void run( Set<Id> AccIds ) {
        List<Account> accountRecords =  [Select id, Name  
                                         From Account
                                         Where Id IN:  AccIds ];
        executeHelper( accountRecords );                  
    }
    //Start method to get All Account which is exetuing batch
    public Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'Select Id, Name ' +
            'FROM Account';
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext BC, List<Account> accounts){
        executeHelper( accounts );
    }
    
    public void finish(Database.BatchableContext BC){
    }
    
    //method to perform record creation of junction object for Account having same name
    public static void executeHelper( List<Account> accounts ) {
        //set to get Account having duplicate name
        Set<String> duplicateNames = new Set<String>();
        for (Account account : accounts)
        {
            duplicateNames.add(account.Name);
        }
        
        
        //map to get Account name and list of AccountIds having same name
        Map<String, List<Account>> mapDuplicateAccNameToIds = new Map<String, List<Account>>();
        for(Account acc : [SELECT id,name FROM Account  where Name IN: duplicateNames AND ID NOT IN : accounts]) {
            if(mapDuplicateAccNameToIds.containsKey(acc.Name)) {
                List<Account> ListDuplicates = mapDuplicateAccNameToIds.get(acc.Name);
                ListDuplicates.add(acc);
                //System.debug('ListDuplicates'+ListDuplicates);
                mapDuplicateAccNameToIds.put(acc.Name, ListDuplicates);
            } else {
                mapDuplicateAccNameToIds.put(acc.Name, new List<Account> { acc });
            }
        }
        System.debug('mapDuplicateAccNameToIds'+mapDuplicateAccNameToIds);
        Map<String,FBG_Family__c> mapAlreadyexistFamily = new Map<String,FBG_Family__c>();
        for(FBG_Family__c existFamily : [select id, Name, Sister_Company__c, Sister_Company2__c FROM FBG_Family__c ]){
            String key = String.valueOf(existFamily.Sister_Company__c) + String.valueOf(existFamily.Sister_Company2__c);
            mapAlreadyexistFamily.put(key,existFamily);

        }
        //System.debug('Already exit'+mapAlreadyexistFamily);
        
        //creating junction object records
        List<FBG_Family__c> ListFBGFamily = new List<FBG_Family__c>();
        if(mapDuplicateAccNameToIds.Size() > 0){
            for (Account acc : accounts)
            {
                if( mapDuplicateAccNameToIds.containsKey(acc.Name) ){
                    System.debug('account'+accounts);
                    List<Account> DuplicateAccount = mapDuplicateAccNameToIds.get(acc.Name);
                    //System.debug('DuplicateAccount'+DuplicateAccount);
                    If(DuplicateAccount.Size() > 0) {
                        for(Account Acc1 : DuplicateAccount ){
                            FBG_Family__c Family =  new FBG_Family__c();
                            Family.Sister_Company__c =  acc.id;
                            if( acc.Id != Acc1.Id){
                                Family.Sister_Company2__c = Acc1.id;
                                String key = String.valueOf(Family.Sister_Company__c) + String.valueOf(Family.Sister_Company2__c);
                                if(!mapAlreadyexistFamily.containsKey(key)){
                                    ListFBGFamily.add(Family); 

                                }
                            } 
                        }
                    }   
                }
                
                system.debug('ListFBGFamily'+ListFBGFamily);
                
            }
        }
        if( ListFBGFamily.Size() > 0 ){
            FBGFamilyTriggerHelper.runTrigger = FALSE;
            Insert ListFBGFamily;
        }
    }
}
i created the test class for it but its not giving me the coverage.
my test  class is given below:-
@istest
public class BatchFBGFamiliesTest {
    Static testmethod void creatingFamilyRecordTest(){
        
        Account acc = new Account();
        acc.Name = 'Test18';
        insert acc;
        Account acc1 = new Account();
        acc1.Name = 'Test18';
        insert acc1;
        Account acc2 = new Account();
        acc2.Name = 'Test18';
        insert acc2;
        test.startTest();
        BatchFBGFamilies obj = new BatchFBGFamilies();
        database.executeBatch(obj);
        test.stopTest();
        List<FBG_Family__c> ListFamily = [SELECT id, Name
                                          FROM FBG_Family__c
                                         ];
        List<FBG_Family__c> ListFamilyHavingFirstAccount = [SELECT id, Name
                                                            FROM FBG_Family__c
                                                            WHERE Sister_Company__c =: acc.id 
                                                            OR Sister_Company2__c =: acc.id
                                                           ];
        List<FBG_Family__c> ListFamilyHavingSecondAccount = [SELECT id, Name
                                                             FROM FBG_Family__c
                                                             WHERE Sister_Company__c =: acc1.id 
                                                             OR Sister_Company2__c =: acc1.id
                                                            ];
        List<FBG_Family__c> ListFamilyHavingThirdAccount = [SELECT id, Name
                                                            FROM FBG_Family__c
                                                            WHERE Sister_Company__c =: acc2.id 
                                                            OR Sister_Company2__c =: acc2.id
                                                           ];
        List<FBG_Family__c> ListFamilyFirstAccountAsCompany1 = [SELECT id, Name
                                                                FROM FBG_Family__c
                                                                WHERE Sister_Company__c =: acc.id 
                                                               ];
        System.assertEquals(6, ListFamily.Size());
        System.assertEquals(4, ListFamilyHavingFirstAccount.Size());
        System.assertEquals(4, ListFamilyHavingSecondAccount.Size());
        System.assertEquals(4, ListFamilyHavingThirdAccount.Size());
        System.assertEquals(2, ListFamilyFirstAccountAsCompany1.Size());
        
        
    }
    static testmethod void RunMethodTest(){
        Account acc = new Account();
        acc.Name = 'Test18';
        insert acc;
        BatchFBGFamilies.run( new Set<Id>{ acc.Id });
    }
} how to cover the remaining part?bold lines are not covering
Any suggestions?
Hi All,
     i have requirement in which i have a juction object called family__c. i have two lookup Sister_Company__c and Sister_Company2__c. i am creating a batch in which i want to create records of Accounts having duplicate names.and both duplicates will go in Sister_Company__c and Sister_Company2__c lookup fields.
     example like Account 'ABC' with record type 'A'. and have 2 more account with same name as 'ABC' having record type 'B',and record type 'C'. than junction object records should created and the fill the fields like:-    Sister_Company__c = 'ABC(A)' and  Sister_Company2__c = 'ABC(B)'. and  2nd record as:-Sister_Company__c = 'ABC(A)' and  Sister_Company2__c = 'ABC(c)' creating two junction records like this for ABC(A).
 i created a batch for it but its giving me null pointer exeption.
 how to solve it?
 my batch is given below:-
 //Batch to create FBGFamily junction records for Account having same name
public class BatchFBGFamilies implements Database.Batchable<sObject> {
    //run method to execute batch on one record
    public static void run( Set<Id> AccIds ) {
        List<Account> accountRecords =  [Select id, Name  
                                         From Account
                                         Where Id IN:  AccIds ];
        executeHelper( accountRecords );                  
    }
    //Start method to get All Account which is exetuing batch
    public Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'Select Id, Name ' +
            'FROM Account';
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext BC, List<Account> accounts){
        executeHelper( accounts );
    }
    
    public void finish(Database.BatchableContext BC){
    }
    
    //method to perform record creation of junction object for Account having same name
    public static void executeHelper( List<Account> accounts ) {
        //set to get Account having duplicate name
        Set<String> duplicateNames = new Set<String>();
        for (Account account : accounts)
        {
            duplicateNames.add(account.Name);
        }
        
        //map to get Account name and list of AccountIds having same name
        Map<String, List<Account>> mapDuplicateAccNameToIds = new Map<String, List<Account>>();
        for(Account acc : [SELECT id,name FROM Account  where Name IN: duplicateNames AND Id NOT IN : accounts]) {
            if(mapDuplicateAccNameToIds.containsKey(acc.Name)) {
                List<Account> ListDuplicates = mapDuplicateAccNameToIds.get(acc.Name);
                ListDuplicates.add(acc);
                mapDuplicateAccNameToIds.put(acc.Name, ListDuplicates);
            } else {
                mapDuplicateAccNameToIds.put(acc.Name, new List<Account> { acc });
            }
        }
        Map<String,FBG_Family__c> mapAlreadyexistFamily = new Map<String,FBG_Family__c>();
        for(FBG_Family__c existFamily : [select id, Name, Sister_Company__c, Sister_Company2__c FROM FBG_Family__c ]){
            String key = String.valueOf(existFamily.Sister_Company__c) + String.valueOf(existFamily.Sister_Company2__c);
            mapAlreadyexistFamily.put(key,existFamily);
        }
        //System.debug('Already exit'+mapAlreadyexistFamily);
        
        //creating junction object records
        List<FBG_Family__c> ListFBGFamily = new List<FBG_Family__c>();
        for (Account acc : accounts)
        {
            List<Account> DuplicateAccount = mapDuplicateAccNameToIds.get(acc.Name);
            System.debug('DuplicateAccount'+DuplicateAccount);
            If(DuplicateAccount.Size()>0) {
                for(Account Acc1 : DuplicateAccount ){

                    FBG_Family__c Family =  new FBG_Family__c();
                    Family.Sister_Company__c =  acc.id;
                    if( acc.Id != Acc1.Id){
                        Family.Sister_Company2__c = Acc1.id;
                        String key = String.valueOf(Family.Sister_Company__c) + String.valueOf(Family.Sister_Company2__c);
                        if(!mapAlreadyexistFamily.containsKey(key)){
                            ListFBGFamily.add(Family); 
                        }
                     } 
                }
            }
        }
        if( ListFBGFamily.Size() > 0 ){
            FBGFamilyTriggerHelper.runTrigger = FALSE;
            Insert ListFBGFamily;
        }
    }
}
 what i am missing? Any suggestions?
 
Hi All,
        i have created the batch in which i am creating  Custom object records for duplicate accounts.
        when i run  the batch i have null pointer exeption at bold lines.
        my batch is given below:-
        
        //Batch to create FBGFamily junction records for Account having same name
public class BatchFBGFamilies implements Database.Batchable<sObject> {
    //run method to execute batch on one record
    public static void run( Set<Id> AccIds ) {
        List<Account> accountRecords =  [Select id, Name  
                                         From Account
                                         Where Id IN:  AccIds ];
        executeHelper( accountRecords );                  
    }
    //Start method to get All Account which is exetuing batch
    public Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'Select Id, Name ' +
            'FROM Account';
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext BC, List<Account> accounts){
        executeHelper( accounts );
    }
    
    public void finish(Database.BatchableContext BC){
    }
    
    //method to perform record creation of junction object for Account having same name
    public static void executeHelper( List<Account> accounts ) {
        //set to get Account having duplicate name
        Set<String> duplicateNames = new Set<String>();
        for (Account account : accounts)
        {
            duplicateNames.add(account.Name);
        }
        
        //map to get Account name and list of AccountIds having same name
        Map<String, List<Account>> mapDuplicateAccNameToIds = new Map<String, List<Account>>();
        for(Account acc : [SELECT id,name FROM Account  where Name IN: duplicateNames AND Id NOT IN : accounts]) {
            if(mapDuplicateAccNameToIds.containsKey(acc.Name)) {
                List<Account> ListDuplicates = mapDuplicateAccNameToIds.get(acc.Name);
                ListDuplicates.add(acc);
                mapDuplicateAccNameToIds.put(acc.Name, ListDuplicates);
            } else {
                mapDuplicateAccNameToIds.put(acc.Name, new List<Account> { acc });
            }
        }
        Map<String,FBG_Family__c> mapAlreadyexistFamily = new Map<String,FBG_Family__c>();
        for(FBG_Family__c existFamily : [select id, Name, Sister_Company__c, Sister_Company2__c FROM FBG_Family__c ]){
            String key = String.valueOf(existFamily.Sister_Company__c) + String.valueOf(existFamily.Sister_Company2__c);
            mapAlreadyexistFamily.put(key,existFamily);
        }
        //System.debug('Already exit'+mapAlreadyexistFamily);
        
        //creating junction object records
        List<FBG_Family__c> ListFBGFamily = new List<FBG_Family__c>();
        for (Account acc : accounts)
        {
            List<Account> DuplicateAccount = mapDuplicateAccNameToIds.get(acc.Name);
            System.debug('DuplicateAccount'+DuplicateAccount);
            for(Account Acc1 : DuplicateAccount ){    //here its giving null pointer exeption
                FBG_Family__c Family =  new FBG_Family__c();
                Family.Sister_Company__c =  acc.id;
                if( acc.Id != Acc1.Id){
                    Family.Sister_Company2__c = Acc1.id;
                    String key = String.valueOf(Family.Sister_Company__c) + String.valueOf(Family.Sister_Company2__c);
                    if(!mapAlreadyexistFamily.containsKey(key)){
                        ListFBGFamily.add(Family); 
                    }
                    
                } 
            }
        }
        if( ListFBGFamily.Size() > 0 ){
            FBGFamilyTriggerHelper.runTrigger = FALSE;
            Insert ListFBGFamily;
        }
    }
}
        how to solve this any suggestions?
 hi All,
i Created a map in which i am taking two ids as key .i created the map as below:-
 Map<Id,FBG_Family__c> mapAlreadyexitFamily = new Map<Id,FBG_Family__c>();
        for(FBG_Family__c existFamily : [select id, Name, Sister_Company__c, Sister_Company2__c FROM FBG_Family__c ]){
            String key = String.valueOf(existFamily.Sister_Company__c) + String.valueOf(existFamily.Sister_Company__c);
            mapAlreadyexitFamily.put(key,existFamily);
        }
but its giving me error:- Invalid id: nullnull.
how can i create a map having two ids as a key and get value related to that key which is  a record.
Any suggestions, how to do it?
Hi All,
        i have requirement in which i want to show custom object(FBG_Family__c) records in lighning component.every record has checkbox besides it and when the checkbox is clicked that record should be removed from the list (not delete from database)component.
        how to do it?
        Any suggestions?
Hi All,
I have a custom object called Family which is a junction object between two accounts. Below is the schema of the object.
Object Name: FBG_Family__c Custom fields:
1)  (Sister_Company__c)--lookup relationship
2)   (Sister_Company2__c)-- lookup relationship  
lets assume we have two accounts,
 Account A, Account B. Lets create an FBG_Family__c records between these two. Every time a FBG_Family__c record is inserted, we have to create another FBG_Family__c record and have to swap the Sister_Company__c  and Sister_Company2__c Ids in the new record.
 i have created a trigger for it which is given below:-
 trigger Trigger_FBGFamily on FBG_Family__c (before insert, before update, 
                                            before delete, after insert, 
                                            after update, after delete) {
                                                
    FBGFamilyTriggerHelper.newFBGFamily = trigger.new;
    FBGFamilyTriggerHelper.oldFBGFamily = trigger.old;
    FBGFamilyTriggerHelper.newMapFBGFamily = trigger.newMap;
    FBGFamilyTriggerHelper.oldMapFBGFamily = trigger.oldMap;   
                                                
       if(!FBGFamilyTriggerHelper.runTrigger) {
        return;
    }
                                                if( Trigger.isAfter ){
                                                    if(Trigger.isInsert ){
                                                        FBGFamilyTriggerHelper.CreatingReverseFamilyRecords(trigger.new);   
                                                    }
                                                    
                                                }
                                            }
    Helper is given below:-
    public class FBGFamilyTriggerHelper {
    public static List<FBG_Family__c> newFBGFamily = new List<FBG_Family__c>();
    public static List<FBG_Family__c> oldFBGFamily = new List<FBG_Family__c>();
    public static Map<Id, FBG_Family__c> newMapFBGFamily = new Map<Id, FBG_Family__c>();
    public static Map<Id, FBG_Family__c> oldMapFBGFamily = new Map<Id, FBG_Family__c>();
    
        public static boolean runTrigger = TRUE;
    
     Public static void CreatingReverseFamilyRecords(List<FBG_Family__c> FBGFamilyIds){
        System.debug('processed'+FBGFamilyIds);
        List<FBG_Family__c> ListFamilyToInsert = New List<FBG_Family__c>();
         For(FBG_Family__c Family : FBGFamilyIds)
        {
            FBG_Family__c ReverseFamily = New FBG_Family__c();
            ReverseFamily.Sister_Company__c = Family.Sister_Company2__c;
            ReverseFamily.Sister_Company2__c = Family.Sister_Company__c;
            ListFamilyToInsert.Add(ReverseFamily);
            System.debug('ReverseFamily'+ListFamilyToInsert);
         }
        if(ListFamilyToInsert.Size() > 0){
          Insert ListFamilyToInsert;
         }
    }
}
when i create a record its giving me errror:-Trigger_FBGFamily: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Trigger_FBGFamily: maximum trigger depth exceeded FBG_Family trigger event AfterInsert
how to solve this error?
i tried implementing variable to stop recursion too but no luck.
Am i missing something in the code?
Any suggestions?
Hi All,
       i am getting this error:-
 System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Trigger_FBGFamily: maximum trigger depth exceeded FBG_Family        i have a requirement in which I have a custom object called  Family which is a junction object between two accounts.
   lets assume we have two accounts, Account A, Account B. Lets create an  Family record between these two. 
  Every time a family record is inserted,
  we have to create another family record and have to swap the  Sister_Company__c and Sister_Company2__c Ids in the new record.
  i created a trigger and trigger helper  given below:-
  trigger Trigger_FBGFamily on FBG_Family__c (before insert, before update, 
                                            before delete, after insert, 
                                            after update, after delete) {
                                                
    FBGFamilyTriggerHelper.newFBGFamily = trigger.new;
    FBGFamilyTriggerHelper.oldFBGFamily = trigger.old;
    FBGFamilyTriggerHelper.newMapFBGFamily = trigger.newMap;
    FBGFamilyTriggerHelper.oldMapFBGFamily = trigger.oldMap;   
                                                
       if(!FBGFamilyTriggerHelper.runTrigger) {
        return;
    }
                                              
                                                if( Trigger.isAfter ){
                                                    if(Trigger.isInsert ){
                                                        FBGFamilyTriggerHelper.CreatingReverseFamilyRecords(trigger.new);   
                                                    }
                                                     
                                                }
                                            }
                    Helper class is given below:-
                    public class FBGFamilyTriggerHelper {
    public static List<FBG_Family__c> newFBGFamily = new List<FBG_Family__c>();
    public static List<FBG_Family__c> oldFBGFamily = new List<FBG_Family__c>();
    public static Map<Id, FBG_Family__c> newMapFBGFamily = new Map<Id, FBG_Family__c>();
    public static Map<Id, FBG_Family__c> oldMapFBGFamily = new Map<Id, FBG_Family__c>();
    
        public static boolean runTrigger = TRUE;

    Public static void CreatingReverseFamilyRecords(List<FBG_Family__c> FBGFamilyIds){
        List<FBG_Family__c> ListFamilyToInsert = New List<FBG_Family__c>();
         For(FBG_Family__c Family : FBGFamilyIds)
        {
            FBG_Family__c ReverseFamily = New FBG_Family__c();
            ReverseFamily.Sister_Company__c = Family.Sister_Company2__c;
            ReverseFamily.Sister_Company2__c = Family.Sister_Company__c;
            ListFamilyToInsert.Add(ReverseFamily);
        }
        if(ListFamilyToInsert.Size() > 0){
          Insert ListFamilyToInsert;
         }
        System.debug('ReverseFamily'+ListFamilyToInsert);
    }
}
How to solve this error?
Any suggestions?
Hi All,
     i have requirement in which i have a juction object called family__c. i have two lookup Sister_Company__c and Sister_Company2__c. i am creating a batch in which i want to create records of Accounts having duplicate names.and both duplicates will go in Sister_Company__c and Sister_Company2__c lookup fields.
     example like Account 'ABC' with record type 'A'. and have 2 more account with same name as 'ABC' having record type 'B',and record type 'C'. than junction object records should created and the fill the fields like:-    Sister_Company__c = 'ABC(A)' and  Sister_Company2__c = 'ABC(B)'. and  2nd record as:-Sister_Company__c = 'ABC(A)' and  Sister_Company2__c = 'ABC(c)' creating two junction records like this for ABC(A).
i am trying to create a batch given below. but not able to take Account which have duplicate name in query .
how will i insert the duplicate Account name in Sister_Company2__c.
how to do this ?
Any suggestions?
My batch is given below:-
public class BatchFBGFamilies implements Database.Batchable<sObject> {
    public static void run( Set<Id> AccIds ) {
          
          List<Account> accountRecords =  [Select id, RecordTypeId,                                                                           RecordType.Name,Name  
                                           From Account
                                           Where Id IN:  AccIds ];
            executeHelper( accountRecords );                  
    }
     public Database.QueryLocator start(Database.BatchableContext BC){
         String query = 'Select id, RecordTypeId, RecordType.Name, Name, ' +
            'RecordType.developerName' +
            'FROM Account' ;
        return Database.getQueryLocator(query);

    }
     public void execute(Database.BatchableContext BC, List<Account> scope){
         executeHelper( scope );
    }
     public void finish(Database.BatchableContext BC){
     }
    public static void executeHelper( List<Account> scope ) {
        List<FBG_Family__c> ListFBGFamily = new List<FBG_Family__c>();
        for (Account acc : scope)
        {
            FBG_Family__c Family =  new FBG_Family__c();
            Family.Sister_Company__c =  acc.id;
            Family.Sister_Company2__c = acc.id;
            ListFBGFamily.add(Family);
        }
      Insert ListFBGFamily;
     }
}
Hi All,
 i have a junction object from Account to Account .i want to create junction records for existing data of account.
 i have record types as - 'PTM','Chachet',Timerack',if Account name is same and record type is diffrent than junction records should be created
 for those accounts.
 how to do it?
 Any suggestions?
Hi All,
i am trying to automate a lightning component . i write a script for it .
but i have a lookup field on it i dont know how to test it?
my script is given below:-
package myPackage;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class FamilyRecords {
    public static void main(String[] args) {
         // declaration and instantiation of objects/variables
        System.setProperty("webdriver.chrome.driver","C:\\Users\\user\\Downloads\\Chromedriver_win32\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        String baseUrl = "https://login.salesforce.com";
        driver.get(baseUrl);
        driver.findElement(By.id("username")).sendKeys("kmalek@fbgholdings.com.sfdcadmin");                        
        driver.findElement(By.id("password")).sendKeys("2&*ZMRrGFSx&");                        
        WebElement login = driver.findElement(By.id("Login"));
        login.submit();
        driver.navigate().to("https://fbg--sfdcadmin.lightning.force.com/lightning/r/Account/001S000000zb9KyIAI/view?0.source=alohaHeader");
        WebElement newpage = driver.findElement(By.cssSelector(".slds-button, .slds-button_neutral, .buttonStyle"));
        newpage.click(); 
        //driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
        driver.navigate().to("https://fbg--sfdcadmin.lightning.force.com/lightning/o/FBG_Family__c/new?nooverride=1&backgroundContext=%2Flightning%2Fr%2FAccount%2F001S000000zb9KyIAI%2Fview%3F0.source%3DalohaHeader&0.source=alohaHeader");
        System.out.println("click submit");
        WebDriverWait wait=new WebDriverWait(driver, 20);
        WebElement namefield = wait.until(
                ExpectedConditions.visibilityOfElementLocated(By.id("5998:0")));
        namefield.sendKeys("June12");
        WebElement namefield2 = wait.until(
                ExpectedConditions.visibilityOfElementLocated(By.id("6103:0")));
        namefield2.sendKeys("June12");
        WebElement Accsubmit = driver.findElement(By.cssSelector(".slds-button, .slds-button--neutral, .uiButton--brand, .uiButton, .forceActionButton"));

        Accsubmit.click();
        System.out.println("record submit");
        WebElement option1 =  driver.findElement(By.cssSelector(".slds-checkbox_faux"));                            
        //This will Toggle the Check box         
        option1.click();    
        driver.close();
        
    }
}User-added image
 
Hi All,
i have a lightning component in which i am taking records of a custom object .here when i click on checkbox the record is removed.
but after reloading the page its coming again in data table i want that this records does not show again in data table.i dont want to delete the record.
how to do it?
Any suggestions?
my component and controller is given below:-
<aura:component controller="FBGFamilyController"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <!--aura:attribute name="PageHeading" type="String" default="Remove  False positive On Click Of Check Box" /-->
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:handler name="init" value="{!this}" action="{!c.doinit}" />
    
    
    <div class="slds-section slds-is-open">
        <h3 class="slds-section__title slds-theme_shade">
            <span class="slds-truncate slds-p-horizontal_small" title="Section Title">Family Records</span>
            <lightning:layoutItem class="right-align">
                <lightning:button label="New" onclick="{!c.createRecord}" class="buttonStyle"/>
            </lightning:layoutItem> 
        </h3>
        <lightning:datatable data="{! v.mydata }" 
                             columns="{! v.mycolumns }" 
                             keyField="Id" 
                             onrowselection="{! c.removeRow }"
                             hideCheckboxColumn="false"
                             />
        
    </div>
</aura:component>
Controller is given below:-
({
    doinit : function(component, event, helper) {
        component.set('v.mycolumns', [
            
            {label: 'Name', fieldName: 'linkName', type: 'url', 
             typeAttributes: {label: { fieldName: 'Name' }, target: '_blank'}},
            /*{label: 'Sister Account ', fieldName: 's1', type: 'url', 
             typeAttributes: {label: { fieldName: 'Sister_Company__r.Name' }, target: '_blank'}},
            {label: 'Sister Account ', fieldName: 's2', type: 'url', 
             typeAttributes: {label: { fieldName: ' Sister_Company2__r.Name' }, target: '_blank'}}*/
            {label: 'Division', fieldName: 'd1', type: 'text'},
            {label: 'Sister Account', fieldName: 's1', type: 'text'},
            {label: 'Sister Account', fieldName: 's2', type: 'text'},
            {label: 'State', fieldName: 'State__c', type: 'text'},
            {label: 'Type', fieldName: 'Type__c', type: 'text'},
            {label: 'Owner', fieldName: 'Oid', type: 'text'}
        ]);
        
        var action = component.get('c.fetchRecords');
        var recordId =  component.get("v.recordId");
        action.setParams({rid : recordId});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var allValues = response.getReturnValue();
                
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s1 = row.Sister_Company__r.Name;
                }
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s2 = row.Sister_Company2__r.Name;
                }
                 for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.d1 = row.Sister_Company__r.RecordType.Name;
                }
                for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.Oid = row.Owner.Name;
                }
                 
                allValues.forEach(function(record){
                    record.linkName = '/'+record.Id;
                });
                /* allValues.forEach(function(record){
                     record.s1 = '/'+record.Sister_Company__r.Id;
                }); 
                 allValues.forEach(function(record){
                    record.s2 = '/'+record.Sister_Company2__r.Id;
                }); */
                console.log("allValues--->>> " + allValues);
                component.set('v.mydata', allValues);
            }
            else if(state === "ERROR") {
                var errors = response.getError();
                if(errors){
                    if(errors[0] && errors[0].message){
                        console.log("Error Message: " + errors[0].message);
                    }
                }
                else{
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    removeRow : function(component, event, helper){
        var selRows = event.getParam('selectedRows');
        
        // Remove the record from the table
        var rows = component.get('v.mydata');
        for (var i = 0; i<selRows.length; i++){    
            var rowIndex = rows.indexOf(selRows[i]);
            console.log('rowIndex---->>> ' + rowIndex);
            var r=rows.splice(rowIndex, 1);   
            
            console.log('rrr---->>> ' + JSON.stringify(r));
            component.set('v.mydata', rows);
        }
    },
    
     createRecord : function (component, event, helper) {
        var createRecordEvent = $A.get("e.force:createRecord");
        createRecordEvent.setParams({
            "entityApiName": "FBG_Family__c"
        });
        createRecordEvent.fire();
    }
    
})
Hi All,
         i am trying to make the lookup field a hyper link which show the Account clicking on it.
my controller  is given below:-
 ({

    doinit : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Record Number ', fieldName: 'linkName', type: 'url', 
             typeAttributes: {label: { fieldName: 'Name' }, target: '_blank'}},
            {label: 'Sister Account ', fieldName: 's1', type: 'url', 
             typeAttributes: {label: { fieldName: 'Sister_Company__c' },value:{fieldName: 'Sister_Company__c.Id'}, target: '_blank'}},
            {label: 'Sister Account ', fieldName: 's2', type: 'url', 
             typeAttributes: {label: { fieldName: ' Sister_Company2__c' },value:{fieldName: 's2'}, target: '_blank'}}

          
        ]);
        
        var action = component.get('c.fetchRecords');
        var recordId =  component.get("v.recordId");
        action.setParams({rid : recordId});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var allValues = response.getReturnValue();
            
                  allValues.forEach(function(record){
                    record.linkName = '/'+record.Id;
                });
               allValues.forEach(function(record){
                    record.s1 = '/'+record.Sister_Company__r.Name;
                }); 
                 allValues.forEach(function(record){
                    record.s2 = '/'+record.Sister_Company2__r.Id;

                }); 
                console.log("allValues--->>> " + allValues);
                component.set('v.mydata', allValues);
            }
            else if(state === "ERROR") {
                var errors = response.getError();
                if(errors){
                    if(errors[0] && errors[0].message){
                        console.log("Error Message: " + errors[0].message);
                    }
                }
                else{
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    removeRow : function(component, event, helper){
        var selRows = event.getParam('selectedRows');
        
        // Remove the record from the table
        var rows = component.get('v.mydata');
        for (var i = 0; i<selRows.length; i++){    
            var rowIndex = rows.indexOf(selRows[i]);
            console.log('rowIndex---->>> ' + rowIndex);
            var r=rows.splice(rowIndex, 1);   
            
            console.log('rrr---->>> ' + JSON.stringify(r));
            component.set('v.mydata', rows);
         }
    }
 })     
                here the name is working as hyper link but on lookup i am getting ids as hyperlink not their name.
                i want lookup field (Sister_Company__c's name as hyper link.
                how to do it?
                Any suggestions?
Hi All,
 i created a ligtning component in which i am showing records of custom object having lookup of account.
i want that it should show only those custom object records which are related to that particular account in which related list  i am using it.
how to do it?
Any suggestions?
My component and controller is given below:-
<aura:component controller="FBGFamilyController"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <aura:attribute name="PageHeading" type="String" default="Remove  False positive On Click Of Check Box" />
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>

    
    <aura:handler name="init" value="{!this}" action="{!c.doinit}" />
    
    <div class="slds-m-top--xx-large">
        <div class="slds-page-header">
            <div class="slds-align--absolute-center">
                <div class="slds-text-heading--large">       
                    {!v.PageHeading}
                </div>
            </div>
        </div>
    </div>
    
 

    
    <div class="slds-section slds-is-open">
        <h3 class="slds-section__title slds-theme_shade">
              <span class="slds-truncate slds-p-horizontal_small" title="Section Title">Family Records</span>
          </h3>
        

        <lightning:datatable data="{! v.mydata }" 
                             columns="{! v.mycolumns }" 
                             keyField="Id" 
                             onrowselection="{! c.removeRow }"
                           />
    </div>
</aura:component>
**********************************
controller is given below:-
({
    doinit : function(component, event, helper) {
        component.set('v.mycolumns', [
           
            {label: 'Record Number', fieldName: 'Name', type: 'integer'},
            
            {label: 'Sister Account', fieldName: 's1', type: 'text'},
            {label: 'Sister Account', fieldName: 's2', type: 'text'}

        ]);
        
        var action = component.get('c.fetchRecords');
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var allValues = response.getReturnValue();
                 for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s1 = row.Sister_Company__r.Name;
                }
                 for (var i = 0; i < allValues.length; i++) {
                    var row = allValues[i];
                    row.s2 = row.Sister_Company2__r.Name;
                }
                console.log("allValues--->>> " + allValues);
                component.set('v.mydata', allValues);
            }
            else if(state === "ERROR") {
                var errors = response.getError();
                if(errors){
                    if(errors[0] && errors[0].message){
                        console.log("Error Message: " + errors[0].message);
                    }
                }
                else{
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    removeRow : function(component, event, helper){
        var selRows = event.getParam('selectedRows');
        
        // Remove the record from the table
        var rows = component.get('v.mydata');
        for (var i = 0; i<selRows.length; i++){    
            var rowIndex = rows.indexOf(selRows[i]);
            console.log('rowIndex---->>> ' + rowIndex);
            var r=rows.splice(rowIndex, 1);   
            console.log('rrr---->>> ' + JSON.stringify(r));
            component.set('v.mydata', rows);
        }
    }
})
******************************************************
public class FBGFamilyController {
        @AuraEnabled
    public static List<FBG_Family__c> fetchRecords() {
        return [SELECT Id, Name, Sister_Company__r.Name, Sister_Company2__r.Name FROM FBG_Family__c];
    }
}
Hi All,
       i have a trigger in which i am inserting reverse records.i have imple mented the trigger its working fine for insertion . now i want that if i update or delete a record its reverse record should also get updated or deleted.
       my trigger is given below:-
       trigger Trigger_FBGFamily on FBG_Family__c (before insert, before update, 
                                            before delete, after insert, 
                                            after update, after delete) {
                                                
    FBGFamilyTriggerHelper.newFBGFamily = trigger.new;
    FBGFamilyTriggerHelper.oldFBGFamily = trigger.old;
    FBGFamilyTriggerHelper.newMapFBGFamily = trigger.newMap;
    FBGFamilyTriggerHelper.oldMapFBGFamily = trigger.oldMap;   
                                                
       if(!FBGFamilyTriggerHelper.runTrigger) {
        return;
    }
                                                if( Trigger.isAfter ){
                                                    if(Trigger.isInsert ){
                                                        FBGFamilyTriggerHelper.CreatingReverseFamilyRecords();   
                                                    }
                                                    
                                                }
                                                 if( Trigger.isBefore ){
                                                    if(Trigger.isDelete ){
                                                        FBGFamilyTriggerHelper.deletingReverseFamilyRecords();   
                                                    }
                                                    
                                                }
                                            }
        my helper class is given below:-
        public class FBGFamilyTriggerHelper {
    public static List<FBG_Family__c> newFBGFamily = new List<FBG_Family__c>();
    public static List<FBG_Family__c> oldFBGFamily = new List<FBG_Family__c>();
    public static Map<Id, FBG_Family__c> newMapFBGFamily = new Map<Id, FBG_Family__c>();
    public static Map<Id, FBG_Family__c> oldMapFBGFamily = new Map<Id, FBG_Family__c>();
    
        public static boolean runTrigger = TRUE;
    
     Public static void CreatingReverseFamilyRecords(){
        System.debug('processed'+newFBGFamily);
        List<FBG_Family__c> ListFamilyToInsert = New List<FBG_Family__c>();
         For(FBG_Family__c Family : newFBGFamily)
        {
            FBG_Family__c ReverseFamily = New FBG_Family__c();
            ReverseFamily.Sister_Company__c = Family.Sister_Company2__c;
            ReverseFamily.Sister_Company2__c = Family.Sister_Company__c;
            ListFamilyToInsert.Add(ReverseFamily);
            System.debug('ReverseFamily'+ListFamilyToInsert);

         }
        if(ListFamilyToInsert.Size() > 0){
            runTrigger = FALSE;
          Insert ListFamilyToInsert;
            runTrigger = TRUE;
           System.debug('ReverseFamily'+ListFamilyToInsert);

         }
    }
    public static void deletingReverseFamilyRecords(){
         //To store Family ids
    list<id> Famids = new list<id>();
    for(FBG_Family__c Family : oldFBGFamily)
    {
        system.debug('old list'+oldFBGFamily);
        Famids.add(Family.id);
    }  
    system.debug('Famids'+Famids);

    //Collecting all records related to Family records
        list<FBG_Family__c> listOfFamilyToDelete = [SELECT id  
                                                    FROM FBG_Family__c 
                                                    WHERE ID IN : Famids
                                                   ];
    system.debug('listOfFamily'+listOfFamilyToDelete);
    //deleting Reverse records
     if(listOfFamilyToDelete.Size() > 0){
     delete listOfFamilyToDelete;
      }  
    }
}
its not working for deletion.
Any suggestion? how to solve it?
Hi All,
 i created the batch given below:-
 //Batch to create FBGFamily junction records for Account having same name
public class BatchFBGFamilies implements Database.Batchable<sObject> {
    //run method to execute batch on one record
    public static void run( Set<Id> AccIds ) {
        List<Account> accountRecords =  [Select id, Name  
                                         From Account
                                         Where Id IN:  AccIds ];
        executeHelper( accountRecords );                  
    }
    //Start method to get All Account which is exetuing batch
    public Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'Select Id, Name ' +
            'FROM Account';
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext BC, List<Account> accounts){
        executeHelper( accounts );
    }
    
    public void finish(Database.BatchableContext BC){
    }
    
    //method to perform record creation of junction object for Account having same name
    public static void executeHelper( List<Account> accounts ) {
        //set to get Account having duplicate name
        Set<String> duplicateNames = new Set<String>();
        for (Account account : accounts)
        {
            duplicateNames.add(account.Name);
        }
        
        
        //map to get Account name and list of AccountIds having same name
        Map<String, List<Account>> mapDuplicateAccNameToIds = new Map<String, List<Account>>();
        for(Account acc : [SELECT id,name FROM Account  where Name IN: duplicateNames AND ID NOT IN : accounts]) {
            if(mapDuplicateAccNameToIds.containsKey(acc.Name)) {
                List<Account> ListDuplicates = mapDuplicateAccNameToIds.get(acc.Name);
                ListDuplicates.add(acc);
                //System.debug('ListDuplicates'+ListDuplicates);
                mapDuplicateAccNameToIds.put(acc.Name, ListDuplicates);
            } else {
                mapDuplicateAccNameToIds.put(acc.Name, new List<Account> { acc });
            }
        }
        System.debug('mapDuplicateAccNameToIds'+mapDuplicateAccNameToIds);
        Map<String,FBG_Family__c> mapAlreadyexistFamily = new Map<String,FBG_Family__c>();
        for(FBG_Family__c existFamily : [select id, Name, Sister_Company__c, Sister_Company2__c FROM FBG_Family__c ]){
            String key = String.valueOf(existFamily.Sister_Company__c) + String.valueOf(existFamily.Sister_Company2__c);
            mapAlreadyexistFamily.put(key,existFamily);

        }
        //System.debug('Already exit'+mapAlreadyexistFamily);
        
        //creating junction object records
        List<FBG_Family__c> ListFBGFamily = new List<FBG_Family__c>();
        if(mapDuplicateAccNameToIds.Size() > 0){
            for (Account acc : accounts)
            {
                if( mapDuplicateAccNameToIds.containsKey(acc.Name) ){
                    System.debug('account'+accounts);
                    List<Account> DuplicateAccount = mapDuplicateAccNameToIds.get(acc.Name);
                    //System.debug('DuplicateAccount'+DuplicateAccount);
                    If(DuplicateAccount.Size() > 0) {
                        for(Account Acc1 : DuplicateAccount ){
                            FBG_Family__c Family =  new FBG_Family__c();
                            Family.Sister_Company__c =  acc.id;
                            if( acc.Id != Acc1.Id){
                                Family.Sister_Company2__c = Acc1.id;
                                String key = String.valueOf(Family.Sister_Company__c) + String.valueOf(Family.Sister_Company2__c);
                                if(!mapAlreadyexistFamily.containsKey(key)){
                                    ListFBGFamily.add(Family); 

                                }
                            } 
                        }
                    }   
                }
                
                system.debug('ListFBGFamily'+ListFBGFamily);
                
            }
        }
        if( ListFBGFamily.Size() > 0 ){
            FBGFamilyTriggerHelper.runTrigger = FALSE;
            Insert ListFBGFamily;
        }
    }
}
i created the test class for it but its not giving me the coverage.
my test  class is given below:-
@istest
public class BatchFBGFamiliesTest {
    Static testmethod void creatingFamilyRecordTest(){
        
        Account acc = new Account();
        acc.Name = 'Test18';
        insert acc;
        Account acc1 = new Account();
        acc1.Name = 'Test18';
        insert acc1;
        Account acc2 = new Account();
        acc2.Name = 'Test18';
        insert acc2;
        test.startTest();
        BatchFBGFamilies obj = new BatchFBGFamilies();
        database.executeBatch(obj);
        test.stopTest();
        List<FBG_Family__c> ListFamily = [SELECT id, Name
                                          FROM FBG_Family__c
                                         ];
        List<FBG_Family__c> ListFamilyHavingFirstAccount = [SELECT id, Name
                                                            FROM FBG_Family__c
                                                            WHERE Sister_Company__c =: acc.id 
                                                            OR Sister_Company2__c =: acc.id
                                                           ];
        List<FBG_Family__c> ListFamilyHavingSecondAccount = [SELECT id, Name
                                                             FROM FBG_Family__c
                                                             WHERE Sister_Company__c =: acc1.id 
                                                             OR Sister_Company2__c =: acc1.id
                                                            ];
        List<FBG_Family__c> ListFamilyHavingThirdAccount = [SELECT id, Name
                                                            FROM FBG_Family__c
                                                            WHERE Sister_Company__c =: acc2.id 
                                                            OR Sister_Company2__c =: acc2.id
                                                           ];
        List<FBG_Family__c> ListFamilyFirstAccountAsCompany1 = [SELECT id, Name
                                                                FROM FBG_Family__c
                                                                WHERE Sister_Company__c =: acc.id 
                                                               ];
        System.assertEquals(6, ListFamily.Size());
        System.assertEquals(4, ListFamilyHavingFirstAccount.Size());
        System.assertEquals(4, ListFamilyHavingSecondAccount.Size());
        System.assertEquals(4, ListFamilyHavingThirdAccount.Size());
        System.assertEquals(2, ListFamilyFirstAccountAsCompany1.Size());
        
        
    }
    static testmethod void RunMethodTest(){
        Account acc = new Account();
        acc.Name = 'Test18';
        insert acc;
        BatchFBGFamilies.run( new Set<Id>{ acc.Id });
    }
} how to cover the remaining part?bold lines are not covering
Any suggestions?
Hi All,
        i have created the batch in which i am creating  Custom object records for duplicate accounts.
        when i run  the batch i have null pointer exeption at bold lines.
        my batch is given below:-
        
        //Batch to create FBGFamily junction records for Account having same name
public class BatchFBGFamilies implements Database.Batchable<sObject> {
    //run method to execute batch on one record
    public static void run( Set<Id> AccIds ) {
        List<Account> accountRecords =  [Select id, Name  
                                         From Account
                                         Where Id IN:  AccIds ];
        executeHelper( accountRecords );                  
    }
    //Start method to get All Account which is exetuing batch
    public Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'Select Id, Name ' +
            'FROM Account';
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext BC, List<Account> accounts){
        executeHelper( accounts );
    }
    
    public void finish(Database.BatchableContext BC){
    }
    
    //method to perform record creation of junction object for Account having same name
    public static void executeHelper( List<Account> accounts ) {
        //set to get Account having duplicate name
        Set<String> duplicateNames = new Set<String>();
        for (Account account : accounts)
        {
            duplicateNames.add(account.Name);
        }
        
        //map to get Account name and list of AccountIds having same name
        Map<String, List<Account>> mapDuplicateAccNameToIds = new Map<String, List<Account>>();
        for(Account acc : [SELECT id,name FROM Account  where Name IN: duplicateNames AND Id NOT IN : accounts]) {
            if(mapDuplicateAccNameToIds.containsKey(acc.Name)) {
                List<Account> ListDuplicates = mapDuplicateAccNameToIds.get(acc.Name);
                ListDuplicates.add(acc);
                mapDuplicateAccNameToIds.put(acc.Name, ListDuplicates);
            } else {
                mapDuplicateAccNameToIds.put(acc.Name, new List<Account> { acc });
            }
        }
        Map<String,FBG_Family__c> mapAlreadyexistFamily = new Map<String,FBG_Family__c>();
        for(FBG_Family__c existFamily : [select id, Name, Sister_Company__c, Sister_Company2__c FROM FBG_Family__c ]){
            String key = String.valueOf(existFamily.Sister_Company__c) + String.valueOf(existFamily.Sister_Company2__c);
            mapAlreadyexistFamily.put(key,existFamily);
        }
        //System.debug('Already exit'+mapAlreadyexistFamily);
        
        //creating junction object records
        List<FBG_Family__c> ListFBGFamily = new List<FBG_Family__c>();
        for (Account acc : accounts)
        {
            List<Account> DuplicateAccount = mapDuplicateAccNameToIds.get(acc.Name);
            System.debug('DuplicateAccount'+DuplicateAccount);
            for(Account Acc1 : DuplicateAccount ){    //here its giving null pointer exeption
                FBG_Family__c Family =  new FBG_Family__c();
                Family.Sister_Company__c =  acc.id;
                if( acc.Id != Acc1.Id){
                    Family.Sister_Company2__c = Acc1.id;
                    String key = String.valueOf(Family.Sister_Company__c) + String.valueOf(Family.Sister_Company2__c);
                    if(!mapAlreadyexistFamily.containsKey(key)){
                        ListFBGFamily.add(Family); 
                    }
                    
                } 
            }
        }
        if( ListFBGFamily.Size() > 0 ){
            FBGFamilyTriggerHelper.runTrigger = FALSE;
            Insert ListFBGFamily;
        }
    }
}
        how to solve this any suggestions?
 hi All,
i Created a map in which i am taking two ids as key .i created the map as below:-
 Map<Id,FBG_Family__c> mapAlreadyexitFamily = new Map<Id,FBG_Family__c>();
        for(FBG_Family__c existFamily : [select id, Name, Sister_Company__c, Sister_Company2__c FROM FBG_Family__c ]){
            String key = String.valueOf(existFamily.Sister_Company__c) + String.valueOf(existFamily.Sister_Company__c);
            mapAlreadyexitFamily.put(key,existFamily);
        }
but its giving me error:- Invalid id: nullnull.
how can i create a map having two ids as a key and get value related to that key which is  a record.
Any suggestions, how to do it?
Hi All,
        i have requirement in which i want to show custom object(FBG_Family__c) records in lighning component.every record has checkbox besides it and when the checkbox is clicked that record should be removed from the list (not delete from database)component.
        how to do it?
        Any suggestions?
Hi All,
       i am getting this error:-
 System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Trigger_FBGFamily: maximum trigger depth exceeded FBG_Family        i have a requirement in which I have a custom object called  Family which is a junction object between two accounts.
   lets assume we have two accounts, Account A, Account B. Lets create an  Family record between these two. 
  Every time a family record is inserted,
  we have to create another family record and have to swap the  Sister_Company__c and Sister_Company2__c Ids in the new record.
  i created a trigger and trigger helper  given below:-
  trigger Trigger_FBGFamily on FBG_Family__c (before insert, before update, 
                                            before delete, after insert, 
                                            after update, after delete) {
                                                
    FBGFamilyTriggerHelper.newFBGFamily = trigger.new;
    FBGFamilyTriggerHelper.oldFBGFamily = trigger.old;
    FBGFamilyTriggerHelper.newMapFBGFamily = trigger.newMap;
    FBGFamilyTriggerHelper.oldMapFBGFamily = trigger.oldMap;   
                                                
       if(!FBGFamilyTriggerHelper.runTrigger) {
        return;
    }
                                              
                                                if( Trigger.isAfter ){
                                                    if(Trigger.isInsert ){
                                                        FBGFamilyTriggerHelper.CreatingReverseFamilyRecords(trigger.new);   
                                                    }
                                                     
                                                }
                                            }
                    Helper class is given below:-
                    public class FBGFamilyTriggerHelper {
    public static List<FBG_Family__c> newFBGFamily = new List<FBG_Family__c>();
    public static List<FBG_Family__c> oldFBGFamily = new List<FBG_Family__c>();
    public static Map<Id, FBG_Family__c> newMapFBGFamily = new Map<Id, FBG_Family__c>();
    public static Map<Id, FBG_Family__c> oldMapFBGFamily = new Map<Id, FBG_Family__c>();
    
        public static boolean runTrigger = TRUE;

    Public static void CreatingReverseFamilyRecords(List<FBG_Family__c> FBGFamilyIds){
        List<FBG_Family__c> ListFamilyToInsert = New List<FBG_Family__c>();
         For(FBG_Family__c Family : FBGFamilyIds)
        {
            FBG_Family__c ReverseFamily = New FBG_Family__c();
            ReverseFamily.Sister_Company__c = Family.Sister_Company2__c;
            ReverseFamily.Sister_Company2__c = Family.Sister_Company__c;
            ListFamilyToInsert.Add(ReverseFamily);
        }
        if(ListFamilyToInsert.Size() > 0){
          Insert ListFamilyToInsert;
         }
        System.debug('ReverseFamily'+ListFamilyToInsert);
    }
}
How to solve this error?
Any suggestions?
Hi All,
i have a batch in which i am updating case field ClosedDate to a field coming from Zendesk Api Solved_at . but when i tried to run the batch its giving me the error :-   System.TypeException: Invalid date: 2019-05-06T13:33:15Z
the api response is in this format:-"solved_at": "2019-04-09T17:43:33Z",
my batch is given below:-


public class BatchZendeskClosedDate implements Database.Batchable<sObject>,Database.AllowsCallouts, Database.Stateful {
        string query;
    public static void run( Set<Id> caseIds ){
        List<Case> caseList = [ SELECT Id, Zd_Zendesk_Id__c  
                                           FROM Case 
                                           WHERE Zd_Zendesk_Id__c != null AND  Id IN: caseIds ];
        executeHelper(caseList);
    }
     public Database.querylocator start(Database.BatchableContext BC){
        query = 'SELECT Id,Zd_Zendesk_Id__c ' +
                'FROM Case ' +
                'WHERE Zd_Zendesk_Id__c != null ';
                 return Database.getQueryLocator(query);
     }
    //execute method to update Case solvedDate
    public void execute( Database.BatchableContext BC, List<Case> caseList){
        executeHelper(caseList);
     }
     public static void executeHelper( List<Case> caseList ){
        List<Case> updateCase = new List<Case>();
        for( Case cs : caseList ){
            HttpRequest req = new HttpRequest();
            req.setMethod( 'GET' );
            String username = System.Label.Zendesk_UserName;
            String password = System.Label.Zendesk_Password;
            Blob headerValue = Blob.valueOf( username + ':' + password );
            String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode( headerValue );
            req.setHeader( 'Authorization', authorizationHeader );
            req.setHeader( 'Content-Type', 'application/json' );
            req.setEndpoint( 'https://timerack.zendesk.com/api/v2/ticket_metrics.json' );
            Http binding = new Http();
            HttpResponse res = binding.send( req );
             Map<String, Object> results = ( Map<String, Object> )JSON.deserializeUntyped( res.getBody() );
            List<Object> lstCases = ( List<Object> )results.get( 'ticket_metrics' );
            List<Map<String, Object>> casesAtt = new List< Map< String, Object >>();
            for ( Object Cases : lstCases ) {
                Map<String, Object> casesAttributes = ( Map< String, Object >)Cases;
                casesAtt.add( casesAttributes );
            }
            //List< case > listCasesToUpdate = new List< case >();
            for( Map< String, Object> attMap : casesAtt ){
                Case ct = new Case(); 
                ct.ClosedDate = Date.valueOf( attMap.get( 'solved_at' ));
                updateCase.add(ct);
             }
         }
        if(updateCase.Size()>0){
            update updateCase;
        }
        
    }
        public void finish(Database.BatchableContext BC){
     }
 }
how to solve this error?
Any suggestions?
hi all,
i have a batch in which i am fetching zendesk contact. how to write test class for it?
My batch class is given below:-
 
public class BatchZendeskToSalesforceCon implements Database.Batchable<String>,Database.AllowsCallouts, Database.Stateful{
    
    // start method to return the list of end points of Zendesk Users
    public Iterable<String> start(Database.BatchableContext BC){
        
        List<Zendesk_Contact__c> conList = new List<Zendesk_Contact__c>();
        List<String> endPoints = new List<String>();
        // instance of class ZendeskApis to call Contacts Api
        ZendeskApis.ContactJSON2Apex firstRecords =  ZendeskApis.ZendeskContactApi();
        
        Integer totalRecords = firstRecords.count;
        if(totalRecords > 100 &&
           totalRecords > 0 &&
           firstRecords.next_page != null && 
           firstRecords.next_page != ''){
               totalRecords = totalRecords / 100;
               for(Integer i= 1; i<= totalRecords+1; i++){
                   String currentEndPoints = firstRecords.next_page;
                   currentEndPoints = currentEndPoints.substringBefore('?');
                   currentEndPoints = currentEndPoints + '?page='+i;
                   endPoints.add(currentEndPoints);
               }
           }else if(totalRecords < 100 && totalRecords > 0){
               String currentEndPoints = 'https://timerack.zendesk.com/api/v2/users.json';
               endPoints.add(currentEndPoints);
           }
        return endPoints;
        
    }
    //Batch size should be 1 only.  
    //execute method to upsert Users
    public void execute( Database.BatchableContext BC, List<String> endPoints){
        List<Zendesk_Contact__c> conList = new List<Zendesk_Contact__c>();
        for(String endPo : endPoints){
           ZendeskApis.ContactJSON2Apex ajNextRecords =  ZendeskApis.ZendeskContactNextApi(endPo);
           conList.addAll(insertContactData(ajNextRecords));
        }
        if(conList.size() > 0){
            insert conList;
        }
        
    }
    // method to insert Users Records into Contact
    public static List<Zendesk_Contact__c> insertContactData(ZendeskApis.ContactJSON2Apex conData){
        List<Zendesk_Contact__c> conList = new List<Zendesk_Contact__c>();
        //ZendeskApis.ZendeskContactApi();
        for(ZendeskApis.ContactUsers conWrapData : conData.users){
            Zendesk_Contact__c con = new Zendesk_Contact__c();
            
            if(conWrapData.id != null){
                con.Zendesk_id__c = String.valueOf(conWrapData.id);
            }
            con.Url__c = conWrapData.url;
            con.Name__c = conWrapData.name;
            con.Email__c = conWrapData.email;
            if(conWrapData.created_at != null){
                con.created_at__c = Date.valueOf(conWrapData.created_at);
            }
            if(conWrapData.updated_at != null){
                con.Updated_at__c = Date.valueOf(conWrapData.updated_at);
            }
            con.Time_zone__c     = conWrapData.time_zone;
            con.iana_time_zone__c = conWrapData.iana_time_zone;
            if(conWrapData.phone != null){
                con.Phone__c = String.valueOf(conWrapData.phone);
            }
            if(conWrapData.shared_phone_number != null){
                con.Shared_phone_number__c = Boolean.valueOf(conWrapData.shared_phone_number);
            }
            if(conWrapData.photo != null){
                con.Photo__c = String.valueOf(conWrapData.photo);
            }
            con.Locale_id__c = conWrapData.locale_id;
            con.Locale__c = conWrapData.locale;
            if(conWrapData.organization_id != null){
                con.Organization_id__c = String.valueOf(conWrapData.organization_id);
            }
            con.Role__c = conWrapData.role;
            con.verified__c = conWrapData.verified;
            con.External_id__c = conWrapData.external_id;
            if(conWrapData.tags != null){
                con.Tags__c = String.valueOf(conWrapData.tags);
            }
            con.Alias__c = conWrapData.alias;
            con.Active__c = conWrapData.active;
            con.Shared__c = conWrapData.shared;
            con.Shared_agent__c = conWrapData.shared_agent;
            if(conWrapData.last_login_at != null){
                con.last_login_at__c     = Date.valueOf(conWrapData.last_login_at);
            }
            if(String.valueOf(conWrapData.two_factor_auth_enabled) != null && 
               String.valueOf(conWrapData.two_factor_auth_enabled) != ''){
                   con.Two_factor_auth_enabled__c = conWrapData.two_factor_auth_enabled;
               }
            con.Signature__c = conWrapData.signature;
            con.Details__c   = conWrapData.details;
            con.Notes__c = conWrapData.notes;
            con.Role_type__c = conWrapData.role_type;
            con.Custom_Role_id__c = conWrapData.custom_role_id;
            con.Moderator__c = conWrapData.moderator;
            con.Ticket_restriction__c = conWrapData.ticket_restriction;
            con.Only_private_comments__c = conWrapData.only_private_comments;
            con.Restricted_agent__c = conWrapData.restricted_agent;
            con.Suspended__c = conWrapData.suspended;
            con.chat_only__c = conWrapData.chat_only;
            con.Default_group_id__c = conWrapData.default_group_id;
            con.Report_csv__c = conWrapData.report_csv;
            if(conWrapData.user_fields != null){
                con.Users_Fields__c = String.valueOf(conWrapData.user_fields);
                ZendeskApis.ContactUser_fields contactUserFields  = conWrapData.user_fields;
                con.Training_Time__c = contactUserFields.training_time;
            }
            if(!conList.Contains(con)){
                conList.add(con);
            }
            
        }
        return conList;
    }
    public void finish(Database.BatchableContext BC){
       Map<String , Zendesk_Contact__c> conEmails = new Map<String, Zendesk_Contact__c>(); 
       for(Zendesk_Contact__c zdConObj : [Select id, email__c , 
                                         Existing_Contact__c 
                                         from Zendesk_Contact__c]){
            if(zdConObj.email__c != Null){
               conEmails.put(zdConObj.email__c , zdConObj);                                     
            }                                      
       }
        List<Zendesk_Contact__c> zdContactToUpdate = new List<Zendesk_Contact__c>();
        if(conEmails.size() > 0 ){
           for(Contact conObj : [Select id, email
                                 from Contact where email IN: conEmails.keySet()]){
                if(conObj.email != Null && conEmails.containsKey(conObj.email)){
                       Zendesk_Contact__c zdCon = conEmails.get(conObj.email);
                       zdCon.Existing_Contact__c = conObj.Id;
                    if(!zdContactToUpdate.contains(zdCon)){
                      zdContactToUpdate.add(zdCon);    
                    }
                                                            
                   }                                      
               } 
        } 
        update zdContactToUpdate;
    }
    
}
Any suggestions?
 how to write its test class?
All,
I'm working on Selenium Test Automation of my App using the LEX.  In Classic, locators are static in that I can reference an ID number or name, whereas it seems the same field/object in LEX has dynamic IDs depending on when I access said element.

HTML from LEX yields:
<a aria-required="true" class="select" aria-disabled="false" aria-haspopup="true" tabindex="0" role="button" aria-label="Enrollment Type" title="" href="javascript:void(0);" data-aura-rendered-by="2944:0" data-interactive-lib-uid="60">--None--</a>

I try to use the bold faced section as a locator, but it changes each time I click on it.  Here's another example of the same elment. As you can see the id is now 90, instead of 60 above.
<a aria-required="true" class="select" aria-disabled="false" aria-haspopup="true" tabindex="0" role="button" aria-label="Enrollment Type" title="" href="javascript:void(0);" data-aura-rendered-by="4995:0" data-interactive-lib-uid="90">--None--</a>

Here's a snippet from classic, where I can always US the same ID.  It never changes.  Has anyone found a solution to this problem for finding element locators in LEX?
<select id="00No000000DyWd7" name="00No000000DyWd7" tabindex="8"><option value="">--None--</option><option value="New Enrollment">New Enrollment</option><option value="Re-Enrollmet">Re-Enrollmet</option><option value="Re-Validation">Re-Validation</option><option value="Information Update">Information Update</option></select>