• Raffaele Messina
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
hi everybody
i've made an lwc that displays all csv files that i have stroed into salesforce internal files storage. These CSVs serve as a backup, in fact i have all the records for a selected object (eg Account) into the csv.
Later the user can decide if he wants to "restore" the backup. In this case when i restore the backup i want to restore also the eventual relatsionship, eg account-contact. how can i implement this logic? Beacuse when inserting records, salesforce assigns new ids, so the relationship won't be maintained

Hi everybody

i have a csv file containing all the recors that i want to insert/update. My question is: How many records can i update/insert with a batch and how can i manage this operation? Do i need to separate the batch in different chuncks? if so, how is it done?
Thanks in advance for your time

Hello everybody

I am currently ttying to insert records into Salesforce using apex; the records i need are saved as .csv files inside Salesforce in the ContentDocument object. I can get the name of the object from the name of the file, that will be for example: backup_Account_mm/dd/yyy. So i can only get the name of the obj as a string.

How can i build the logic for inserting records (.csv file) based on the object, considering that the objects can change, and i'd rather not use hard coding.

Thanks in advance 

Hi everybody

i have a csv file containing all the recors that i want to insert/update. My question is: How many records can i update/insert with a batch and how can i manage this operation? Do i need to separate the batch in different chuncks? if so, how is it done?
Thanks in advance for your time

Hi,

So I have the below code and I know it works okay 
 
global class MarketingClicks implements Schedulable {
    global void execute(SchedulableContext ctx) {
        List<Lead> Leadlist = [SELECT Id, Campaign_Name__c FROM Lead WHERE Campaign_Name__c != ''];

  if(!LeadList.isEmpty()){
        for(Lead L : LeadList)
        {        
            //Create Marketing Click
            L.Link_Type__c = 'TEST';
            Pardot_Campaign__c PC = new Pardot_Campaign__c();
            PC.Lead__c = L.Id;
            PC.Name = L.Campaign_Name__c;
            insert PC;
            L.Campaign_Name__c= '';
            Update L;
            }
        }
        System.debug(Leadlist);
    }
    
}

I have also added in 4 schedules which trigger this: 
 
System.schedule('Marketing Clicks Job 1', '0 0 * * * ?', new MarketingClicks ());
System.schedule('Marketing Clicks Job 2', '0 15 * * * ?', new MarketingClicks ());
System.schedule('Marketing Clicks Job 3', '0 30 * * * ?', new MarketingClicks ());
System.schedule('Marketing Clicks Job 4', '0 45 * * * ?', new MarketingClicks ());
Again this works fine from what i'm seeing. 

I've then tried to write a test class by following a video and changing the fields that I need instead of what the video was using and it doesn't work can someone help please? 

Test Class: 
@isTest
Public Class MarketingClicksTest
{
  @testSetup
    static void setup()
    {
        List<Lead> Leadlist = new List<Lead>();
        for(Integer i=1;i<=10;i++)
        {
         Lead Id = new Lead(Company='Test',Lastname='sam',Status='Open',UK_Canada__c='UK',Phone='000000',Online_Offline__c='Offline',Enquiry_Source__c='Cold Call',Method__c='N/A',Position__c='UNASSIGNED',Industry_Sector__c='Miscellaneous',Campaign_Name__c='Test');
        }
        insert LeadList;
    }
    
    static testmethod void testMarketingClicksScheduleJob()
    {
        string sch='0 5 12 10 2 ?';
        Test.startTest();
        string jobId=system.schedule('scheduleApexTest',sch,new MarketingClicks());
        List<Lead> LeadList=[SELECT Id, Campaign_Name__c FROM Lead WHERE Campaign_Name__c != ''];
        system.assertEquals(10, Leadlist.size());
        Test.stopTest();
    }
}


Thanks in advance