• kumud thakur 20
  • NEWBIE
  • 160 Points
  • Member since 2016

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 24
    Replies
Hi All, 

I have hardcoded client id and client secret in my code. Salesforce review mentioned to use protected custom settings to store sensitive information. 

So, I created a protected custom setting with two fields client id and client secret. I saved the values in it at  Default Organization Level Value. This custom setting is added to my managed package.

I am able to access it in the developer org, but if my package is installed in another org, it returns null. Below is the code used to access the client id
Access_Key__c authTokenSetting = Access_Key__c.getOrgDefaults();
String rawcryptoKey = authTokenSetting.UniqueEntry__Crypto_Key__c;
System.debug(LoggingLevel.DEBUG, 'Raw crypto key:    ' + rawcryptoKey);

 
I'm working on a Workflow Rule for a picklist value to trigger an out date of NOW() in a Date/Time field but I'm getting this error and can't figure out whats wrong:

IF(ISPICKVAL(Pre_Ground_Break_Ready_to_Send__c, "Yes"), Now()

Error: Syntax error. Missing ')'

Anybody have and idea why this isn't working. I've tried several things to no avail. 
I am trying to create a simple reference table that our support agents can see on the case record.  I don't need it to contain data from Salesforce only pre-defined text.  I would like it to have 2 columns and 4 rows.  It will be somewhat similar to the image I have inserted.  I'm not a developer so I was wondering if someone could provide a sample of something similar they have to help get me started.  Thanks in advance for your help!User-added image
 Public Void setDeletedOrgUnitvalues(Map<String,String> mapAccOrgUnit){
        
            List<Account> accObj2= [Select Id,REX_Territory_Level_7__c,REX_Territory_Level_8__c,REX_Customer_Manager__c from Account where Id In (Select ACCL__Account__c From ACCL__Account_Manager__c where ACCL__Account__c NOT IN:mapAccOrgUnit.keyset())];
        for (Account acc1 :accObj2){
            acc1.REX_Territory_Level_8__c = null;
             acc1.REX_Territory_Level_7__c = null;
             acc1.REX_Customer_Manager__c  = null;
            Database.update(acc1);
        }
        
        List<Account> accObj3= [Select Id,REX_Territory_Level_7__c,REX_Territory_Level_8__c,REX_Customer_Manager__c from Account where (REX_Territory_Level_7__c <> null  OR REX_Territory_Level_8__c <> null Or REX_Customer_Manager__c <> Null) and ID NOT IN:mapAccOrgUnit.keyset()];
        for (Account acc2 :accObj3){
            acc2.REX_Territory_Level_8__c = null;
             acc2.REX_Territory_Level_7__c = null;
             acc2.REX_Customer_Manager__c  = null;
            Database.update(acc2);
        }
        
    }
Hi all,

When I press the lookup button on a field, It shows only the recently viewed items.

Is it possible to show all the lookup items.

Thanks in advance
how we heroku connect for data archival? I used it, but when i deleted record from salesforce it also delete from the heroku ?
Can we use single instance of Heroku for multiple salesforce orgs? I need to do data archival of more than one orgs of salesforce into heroku one instance?
Trying to automate the sending of surveys through email on Salesforce by using a process builder. Need a special code to take the year out of the date field so the emails can be sent twice a year around the renewal  month and not just the year of the renewal.
Hi All, 

I have hardcoded client id and client secret in my code. Salesforce review mentioned to use protected custom settings to store sensitive information. 

So, I created a protected custom setting with two fields client id and client secret. I saved the values in it at  Default Organization Level Value. This custom setting is added to my managed package.

I am able to access it in the developer org, but if my package is installed in another org, it returns null. Below is the code used to access the client id
Access_Key__c authTokenSetting = Access_Key__c.getOrgDefaults();
String rawcryptoKey = authTokenSetting.UniqueEntry__Crypto_Key__c;
System.debug(LoggingLevel.DEBUG, 'Raw crypto key:    ' + rawcryptoKey);

 
I have a text field on Account object which on the standard salesforce pages displays Chinese characters correctly, but when I add the same field on a visualforce page, Chinese text is replaced by question marks.
I’m assuming I need to load additional fonts on the page, but I’m not certain what the solution is.
Does anyone have any suggestion?
 
Hello forum, I am having trouble atchieving 75% code coverage on a trigger im writting and wondered if someone here knows what I am doing incorrectly. I am deleting code and asserting after the fact. Below you can find my trigger as well as the test class and main class. I use a custom testDataFactory to produce my data. 

TRIGGER:
/**
* ─────────────────────────────────────────────────────────────────────────────────────────────────┐
* Rate Review Attachment Counter Trigger Class 
*
* This class is designed to trigger RateReviewAttachmentCounter when the attachment in question is
* related to a Rate_Review__c object
* ──────────────────────────────────────────────────────────────────────────────────────────────────
* @author         William L. Roach-Barrette   <REDACTED>
* @modifiedBy     
* @maintainedBy   
* @version        1.0
* @created        2019-04-16
* @modified       YYYY-MM-DD
* ──────────────────────────────────────────────────────────────────────────────────────────────────
* @changes
* vX.X            EMAIL
* YYYY-MM-DD      Explanation of the change.  Multiple lines can be used to explain the change, but
*                 each line should be indented till left aligned with the previous description text.
*
* vX.X            EMAIL
* YYYY-MM-DD      Each change to this file should be documented by incrementing the version number,
*                 and adding a new entry to this @changes list. Note that there is a single blank
*                 line between each @changes entry.
* ─────────────────────────────────────────────────────────────────────────────────────────────────┘
*/
trigger RateReviewAttachmentTrigger on Attachment (after insert, after update, after delete) {
    if(Trigger.isInsert || Trigger.isUpdate){
        List<Attachment> approved = new List<Attachment>();
    	for(Attachment aiq: Trigger.new){
        	Id parentId = aiq.ParentId;
        	if(parentId.getSObjectType().getDescribe().getName() == 'Rate_Review__c'){
            	approved.add(aiq);
        	}
    	}
        RateReviewAttachmentCounter instance = new RateReviewAttachmentCounter();
        instance.attachmentCounter(approved);
	}
    //when handling a delete you want to pull data from trigger.old and not trigger.new
    if(Trigger.isAfter && Trigger.isdelete){
         List<Attachment> oldboys = new List<Attachment>();
    	for(Attachment aiq: Trigger.old){
        	Id parentId = aiq.ParentId;
        	if(parentId.getSObjectType().getDescribe().getName() == 'Rate_Review__c'){
            	oldboys.add(aiq);
        	}
    }
        RateReviewAttachmentCounter oldinstance = new RateReviewAttachmentCounter();
        oldinstance.attachmentCounter(oldboys);
}
}

MAIN CLASS: 
/**
* ─────────────────────────────────────────────────────────────────────────────────────────────────┐
* Rate Review Attachment Counter Main Class 
*
* This class is designed to monitor the number of attachments produced and attached to the RateReview
* object. This is to be used so that a salesperson cant create a new ratereview record without asscoiating
* at least one attached review with it. 
* ──────────────────────────────────────────────────────────────────────────────────────────────────
* @author         William L. Roach-Barrette   <REDACTED>
* @modifiedBy     
* @maintainedBy   
* @version        1.0
* @created        2019-04-16
* @modified       YYYY-MM-DD
* ──────────────────────────────────────────────────────────────────────────────────────────────────
* @changes
* vX.X            EMAIL
* YYYY-MM-DD      Explanation of the change.  Multiple lines can be used to explain the change, but
*                 each line should be indented till left aligned with the previous description text.
*
* vX.X            EMAIL
* YYYY-MM-DD      Each change to this file should be documented by incrementing the version number,
*                 and adding a new entry to this @changes list. Note that there is a single blank
*                 line between each @changes entry.
* ─────────────────────────────────────────────────────────────────────────────────────────────────┘
*/
public class RateReviewAttachmentCounter{
    
    public void attachmentCounter(List<Attachment> attachList){
        List<Rate_Review__c> rrList = new List<Rate_Review__c>();
    	List<Id> rrIdList = new List<Id>();
        List<Attachment> relatedAttachment = new List<Attachment>();
        for(Attachment attachy: attachList){
            rrIdList.add(attachy.ParentId);
            
        }
        rrList = [SELECT id, Number_of_Attachments__c FROM Rate_Review__c WHERE id IN: rrIdList];
        relatedAttachment = [SELECT id, parentId FROM Attachment WHERE parentId IN: rrIdList];
        
        for(Rate_Review__c rr: rrList){
            Integer attachmentCounter = 0;
            id RateReviewId = rr.id;
            for(Attachment atch: relatedAttachment){
                if(atch.parentId == RateReviewId){
                    attachmentCounter++;
                }
                
            }
            rr.Number_of_Attachments__c = attachmentCounter;
            
        }
        update rrList;
    }

}

TEST CLASS:
/**
* ─────────────────────────────────────────────────────────────────────────────────────────────────┐
* Rate Review Attachment Counter Test Class 
*
* This class is designed to test RateReviewAttachmentCounter when the attachment in question is
* related to a Rate_Review__c object
* ──────────────────────────────────────────────────────────────────────────────────────────────────
* @author         William L. Roach-Barrette   <william.roach@pushpay.com>
* @modifiedBy     
* @maintainedBy   
* @version        1.0
* @created        2019-04-16
* @modified       YYYY-MM-DD
* ──────────────────────────────────────────────────────────────────────────────────────────────────
* @changes
* vX.X            EMAIL
* YYYY-MM-DD      Explanation of the change.  Multiple lines can be used to explain the change, but
*                 each line should be indented till left aligned with the previous description text.
*
* vX.X            EMAIL
* YYYY-MM-DD      Each change to this file should be documented by incrementing the version number,
*                 and adding a new entry to this @changes list. Note that there is a single blank
*                 line between each @changes entry.
* ─────────────────────────────────────────────────────────────────────────────────────────────────┘
*/
@isTest
public class RateReviewAttachmentCounterTest {

    //The test setup was omitted from this class because governing limits are not a concern when testing and its easier to get direct access to 
    //produced data then it is to produce the data and querry for it in later tests. 
	/*@TestSetup
    public static void setup(){
        TestDataFactory dataGenerator = new TestDataFactory();
        Integer numRecords = 1;
        List<Rate_Review__c> rrList = new List<Rate_Review__c>(dataGenerator.generateRateReview(numRecords));
        System.assert(rrList.size() == numRecords, 'INCORRECT NUMBER OF RECORDS PRODUCED. REQUIRED: ' + numRecords + ' ACTUAL: ' + rrList.size());
       
        
    }
*/

    static testmethod void testAttachmentCounter(){
        TestDataFactory dataGenerator = new TestDataFactory();
        Integer numRecords = 5;//NumRecords dictates the total number of records produced for testing purposes. Increment for bulk testing and decrement for easy to read logs
        List<Rate_Review__c> rrList = new List<Rate_Review__c>(dataGenerator.generateRateReview(numRecords));
        System.assert(rrList.size() == numRecords, 'INCORRECT NUMBER OF RECORDS PRODUCED. REQUIRED: ' + numRecords + ' ACTUAL: ' + rrList.size());
        System.debug('RATE REVIEW OBJECTS: ' + rrList);
        List<Attachment> attachmentList = new List<Attachment>(dataGenerator.generateAttachments(rrList, numRecords));
        System.debug('ATTACHMENT LIST: ' + attachmentList);
        List<Id> rrIdList = new List<Id>();
        for(Rate_Review__c rateReview: rrList){
            rrIdList.add(rateReview.id);
        }
        Test.startTest();
        RateReviewAttachmentCounter methodtest = new RateReviewAttachmentCounter();
        methodtest.attachmentCounter(attachmentList);
        Test.stopTest();
        
        rrList = [SELECT id, Number_of_Attachments__c FROM Rate_Review__c WHERE id IN: rrIdList];
        System.assert(rrList.size() == numRecords, 'NOT ENOUGH RATE REVIEWS. EXPECTED: ' + numRecords + ' ACTUAL: ' + rrList.size() );
        for(Rate_Review__c rrfinal: rrList){
            System.assert(rrfinal.Number_of_Attachments__c == numRecords, 'NUM OF ATTACHMENTS NOT SET');
            System.debug('NUMBER OF ATTACHMENTS FIELD: ' + rrfinal.Number_of_Attachments__c);
        
        }
    }
        static testmethod void testAttachmentCounterDelete(){
        Test.startTest();
        TestDataFactory dataGenerator = new TestDataFactory();
        Integer numRecords1 = 5;//NumRecords dictates the total number of records produced for testing purposes. Increment for bulk testing and decrement for easy to read logs
        List<Rate_Review__c> rrList = new List<Rate_Review__c>(dataGenerator.generateRateReview(numRecords1));
        System.assert(rrList.size() == numRecords1, 'INCORRECT NUMBER OF RECORDS PRODUCED. REQUIRED: ' + numRecords1 + ' ACTUAL: ' + rrList.size());
        System.debug('RATE REVIEW OBJECTS: ' + rrList);
        List<Attachment> attachmentList = new List<Attachment>(dataGenerator.generateAttachments(rrList, numRecords1));
        System.debug('ATTACHMENT LIST: ' + attachmentList);
        List<Id> rrIdList = new List<Id>();
        for(Rate_Review__c rateReview: rrList){
            rrIdList.add(rateReview.id);
        }
        
        RateReviewAttachmentCounter methodtest = new RateReviewAttachmentCounter();
        methodtest.attachmentCounter(attachmentList);
        
            delete attachmentList;
       
         Test.stopTest();
        rrList = [SELECT id, Number_of_Attachments__c FROM Rate_Review__c WHERE id IN: rrIdList];
        System.assert(rrList.size() == numRecords1, 'NOT ENOUGH RATE REVIEWS. EXPECTED: ' + 0 + ' ACTUAL: ' + rrList.size() );
        for(Rate_Review__c rrfinal: rrList){
            System.assert(rrfinal.Number_of_Attachments__c == 0 , 'NUM OF ATTACHMENTS NOT SET EXPECTED: ' + rrfinal.Number_of_Attachments__c + ' ACTUAL: ' + numRecords1);
            System.debug('NUMBER OF ATTACHMENTS FIELD: ' + rrfinal.Number_of_Attachments__c);
        
        }

       
        
    }
}

I currently have 56% code coverage on my trigger and 100% coverage on my main class. 
User-added image
I'm working on a Workflow Rule for a picklist value to trigger an out date of NOW() in a Date/Time field but I'm getting this error and can't figure out whats wrong:

IF(ISPICKVAL(Pre_Ground_Break_Ready_to_Send__c, "Yes"), Now()

Error: Syntax error. Missing ')'

Anybody have and idea why this isn't working. I've tried several things to no avail. 
I have the following piece of code that I am unable to figure out how to include in test. I've tried a couple of different ways but I am unable to get Line 8 included in the test scenario. Any help is greatly appreciated!! 
 
trigger SetCaseDetails on Case (before insert, before update) {
    Id ITSRecordID = O__c.getOrgDefaults().ITS_Case_Record_Type__c;
    Id TechRecordID = O__c.getOrgDefaults().TechSupportID__c;
    Map<Id, Case> parentCaseOwners = new Map<Id, Case>();
    Map<String, Repair_History__c> repairHistories = new Map<String, Repair_History__c>();
    for (Case c : Trigger.new) {
        if (c.ParentId != null &  c.Parent.Is_Owner_Active__c != false) {
            parentCaseOwners.put(c.ParentId, null);
        }
        if (c.SO__c != null) {
            repairHistories.put(c.SO__c, null);
        } if (c.Status == 'Closed' || c.Status == 'No Bid' || c.Status == 'Complete' || c.Status == 'Cancelled') {
            c.Open_Lookup__c = null;
       } else if (c.AccountId != null) {
            c.Open_Lookup__c = c.AccountId;
        }
    }    
    if (!parentCaseOwners.isEmpty()) {
        for (Case pc: [SELECT Id, OwnerId FROM Case WHERE Id in :parentCaseOwners.keySet()]) {
            parentCaseOwners.put(pc.Id,pc);
        }        
        for (Case c : Trigger.new) {
            if (c.ParentId != null & c.RecordTypeID != ITSRecordID & c.RecordTypeID != TechRecordID & c.Parent.Is_Owner_Active__c != false) 
				          
            {
                c.OwnerId = parentCaseOwners.get(c.ParentId).OwnerId;
            }
        }
    }

My test code:
 
@isTest
private class TestSetCaseDetails {
 	static testMethod void test() {    
 	Profile pf= [Select Id from profile where Name='System Administrator' limit 1]; 
        
        String orgId=UserInfo.getOrganizationId(); 
        String dateString=String.valueof(Datetime.now()).replace(' ','').replace(':','').replace('-','') ;
        Integer RandomId=Integer.valueOf(Math.rint(Math.random()*1000000)); 
        String uniqueName=orgId+dateString+RandomId; 
        User uu=new User(firstname = 'ABC', 
                         lastName = 'XYZ', 
                         email = uniqueName + '@test' + orgId + '.org', 
                         Username = uniqueName + '@test' + orgId + '.org', 
                         EmailEncodingKey = 'ISO-8859-1', 
                         Alias = uniqueName.substring(18, 23), 
                         TimeZoneSidKey = 'America/Los_Angeles', 
                         LocaleSidKey = 'en_US', 
                         LanguageLocaleKey = 'en_US', 
                         ProfileId = pf.Id,
                         isActive = True
                        ); 
      	insert uu;
      	system.debug('User active ' + uu.IsActive);
      
	System.runAs(uu){
		
        List<Repair_History__c> repairhistories = new List<Repair_History__c>();
        List<Case> caseowners = new List<Case>();
      
      	Map<id,Case> parentCaseOwners = new Map<id,Case>();
      
      	Id caserec = Schema.SObjectType.Case.getRecordTypeInfosByName().get('BA Support Case').getRecordTypeId();
      
        Account a1 = new Account(
            Name='A1',
            BillingStreet = 'Street',
            BillingCity = 'City',
            BillingPostalCode = 'Postal Code',
            BillingState = 'ON',
            BillingCountry = 'Country'        
        );
        insert a1;
        
        case c1 = new Case(
        	Status='New',
        	Origin='Email',
			SO__c='12345678',
            subject='parent case',
            Open_Lookup__c=a1.id,
            accountid=a1.id,
            ownerid=uu.Id
        	);
        insert c1;
        c1 = [select id, Is_Owner_Active__c from Case where id=:c1.id];
        system.debug('Case User Is active: ' + c1.Is_Owner_Active__c);
      	
        caseowners.add(c1);
        parentCaseOwners.put(c1.id, c1);
      
     	case c2 = new Case(
        	Status='Closed',
        	Origin='Email',
            subject='child case',
			Parentid=c1.Id,
            SO__c='12345678',
            RecordTypeId=caserec
        	);
        //insert c2;
        c2 = [select id, Is_Owner_Active__c from Case where id=:c1.id];
        system.debug('Child Case User Is active: ' + c2.Is_Owner_Active__c);
        parentCaseOwners.put(c2.id, c2);
      
      case c3 = new Case(
        	Status='Closed',
        	Origin='Email',
            subject='child case',
            Parentid=c1.Id,
            SO__c='12345678'
        	);
        insert c3;
        c3 = [select id, Is_Owner_Active__c from Case where id=:c3.id];
      	caseowners.add(c2);
        caseowners.add(c3);
        
        Account a2 = new Account(
            Name = 'A2',
            JDE_Account_Number__c='JDE',
            ParentId=a1.Id,
            BillingStreet = 'Street',
            BillingCity = 'City',
            BillingPostalCode = 'Postal Code',
            BillingState = 'ON',
            BillingCountry = 'Country'
        );
        insert a2;
        
		
		Product2 prod = new Product2(Name = 'Laptop X200', 
                                     Family = 'Hardware');
        insert prod;
        
		
		
      	Repair_History__c p1 = new Repair_History__c();
            p1.Repair_Number__c  = '123456';
            p1.Total_Price__c  = 100;
            p1.Account__c = a1.Id;
		p1.product__c = prod.Id;
            insert p1;
      
      	Repair_History__c p2 = new Repair_History__c();
            p2.Repair_Number__c  = '1234567';
            p2.Total_Price__c  = 100;
            p2.Account__c = a2.Id;
				 p2.product__c = prod.Id;
            insert p2;
      
      	repairhistories.add(p1);
        repairhistories.add(p2);
      
    }
  }
}

 
I am trying to create a simple reference table that our support agents can see on the case record.  I don't need it to contain data from Salesforce only pre-defined text.  I would like it to have 2 columns and 4 rows.  It will be somewhat similar to the image I have inserted.  I'm not a developer so I was wondering if someone could provide a sample of something similar they have to help get me started.  Thanks in advance for your help!User-added image
 Public Void setDeletedOrgUnitvalues(Map<String,String> mapAccOrgUnit){
        
            List<Account> accObj2= [Select Id,REX_Territory_Level_7__c,REX_Territory_Level_8__c,REX_Customer_Manager__c from Account where Id In (Select ACCL__Account__c From ACCL__Account_Manager__c where ACCL__Account__c NOT IN:mapAccOrgUnit.keyset())];
        for (Account acc1 :accObj2){
            acc1.REX_Territory_Level_8__c = null;
             acc1.REX_Territory_Level_7__c = null;
             acc1.REX_Customer_Manager__c  = null;
            Database.update(acc1);
        }
        
        List<Account> accObj3= [Select Id,REX_Territory_Level_7__c,REX_Territory_Level_8__c,REX_Customer_Manager__c from Account where (REX_Territory_Level_7__c <> null  OR REX_Territory_Level_8__c <> null Or REX_Customer_Manager__c <> Null) and ID NOT IN:mapAccOrgUnit.keyset()];
        for (Account acc2 :accObj3){
            acc2.REX_Territory_Level_8__c = null;
             acc2.REX_Territory_Level_7__c = null;
             acc2.REX_Customer_Manager__c  = null;
            Database.update(acc2);
        }
        
    }
The visual force have two fields : 1 st one is text field and other one is a picklist.

The picklist need to be loaded dynamically based on input text field. 
Is it possible in visualforce ? I am good to load the data on button click as well.

Thanks in advance for any inputs.
Hi,

I've created a simple class to retrieve several custom metadata settings. How do I create a test class for this? I've tried a couple of different variations with no luck.

public with sharing class deadlineDatesController {
    @AuraEnabled
    public static List <CustomMeta__mdt> getProdDates() {

        List < CustomMeta__mdt> prodList = [SELECT MasterLabel,
                                                             value1__c,
                                                             Value2__c

                                                       FROM CustomMeta__mdt
                                                        ]; {

            system.debug('prodList' + prodList);
            return prodList;
        }
    }
Hello I would like to rollup a field value from all of the assets on an account up to that account's field. Currently, the trigger is updating the account field, but it's overwriting the existing value, and not collecting the asset field values. On line 24 I'm getting an error of illegal assignment from set to string (ProductsOwned_c += prodFam.clone()). 

I'm trying to take all of the unique string values in the ProdFam set variable and load them into the ProductsOwned__ field. Can I load a collection into a text field? Thank you for your help.  

trigger BulkifyAssets on Asset (before insert, before update) {
    Set<Id> accountId = new Set<Id>();
    Map<Id, Account> parentRecords = new Map<Id, Account>();
    Map<String,Account> accProductsOwnedMap = new Map<String,Account>();
    Set<String> prodFam = new Set<String>();
   
for(Asset a: trigger.new){
    if(a.Status != null || a.status != 'Retired' || a.status != 'Obsolete' )
    accountId.add(a.AccountId);
    accountId.remove(null);
    String prodFamAccount = a.ProductFamily__c;
    prodFam.add(prodFamAccount);
   
   
    for(Id parentId: accountId){
        String prodFamSingle;
       
        for(String f: prodFam)
                    parentRecords.put(parentId, new Account(Id = parentId, ProductsOwned__c =+ prodFam.clone()));
 
       
        for(Asset asset: [Select Id, ProductFamily__c, AccountId from Asset Where Id In: accountId]){
           if(parentRecords.get(asset.AccountId).ProductsOwned__c != null){
           parentRecords.get(asset.AccountId).ProductsOwned__c += ',' + parentRecords.values();
        }
        else{
     parentRecords.get(asset.AccountId).ProductsOwned__c += ',' + parentRecords.values();             
        }
        }
   
    if(parentRecords.size()>0)
    {
   update parentRecords.values();
}  
}
}
}
 
  • April 11, 2019
  • Like
  • 0
Hi,

i am cponverting my lead to person account using the below code. I want to clone the attachment in lead to person account as well. How do i do it?
trigger LeadCreateAccount on Lead (Before Insert) {
    Public List<Account> lstAccts = new List<Account>();
    Public List<Account> lstNewAccts = new List<Account>();
    Public set<String> setLeadNames = new set<String>();
    public String name = '';
    Id personAccountRecordTypeId =  Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('PersonAccount').getRecordTypeId();
   
 for(Lead l: trigger.new)
    {
        
        Account acct = new account();
        acct.FirstName = l.firstname;
        acct.LastName = l.lastname;
        acct.Email__c = l.Email;
        acct.RecordTypeId = personAccountRecordTypeId;
        lstNewAccts.add(acct);
        
    }
    
    if (lstNewAccts.size() > 0)
        insert lstNewAccts;

}

 
  • April 11, 2019
  • Like
  • 0