• Singamsetti Sai Teja
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 6
    Replies

Hi

I am not able to select the loop variable in the loop element.

To query the record collection varibale and store in single variable it is not popping up.

Am I missing some setup options??
What Could be the issue ?????Attaching screenshot

 Loop element

global class LeadProcessor implements Database.Batchable<sObject> {
    
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([SELECT LeadSource from Lead]);
    }
    
    global void execute(Database.BatchableContext bc, List<Lead> scope){
        for(Lead Leads : scope){
            Leads.LeadSource = 'Dreamforce';
        }
        update scope;
    }
    
    global void finish(Database.BatchableContext bc){
        
    }
}




@isTest
public class LeadProcessorTest {
    static testMethod void leadProcessorTrailTest(){
        List<Lead> leadList = new List<Lead>();
        for(integer i = 0; i<200; i++){
            Lead leads = new Lead();
            leads.FirstName = 'Ankit';
            leads.LastName = 'Avula'+i;
            leads.Company = 'ARG';
            leadList.add(leads);           
        }
        insert leadList;
        Test.startTest();
        LeadProcessor L = new LeadProcessor();
//l.execute(null,[select leadsource from lead]);
        Database.executeBatch(L);
        Test.stopTest();
    }

}

Hi

I am not able to select the loop variable in the loop element.

To query the record collection varibale and store in single variable it is not popping up.

Am I missing some setup options??
What Could be the issue ?????Attaching screenshot

 Loop element

After creating a process in the process builder, I set the obj to Opportunity and the criteria to match the Acc type with Prospect or Customer, but when, in the immediate actions, try to set the email, I don't get the template that's supposed to be there since it's been installed with the package. 

Can anyone help?
global class LeadProcessor implements Database.Batchable<sObject> {
    
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([SELECT LeadSource from Lead]);
    }
    
    global void execute(Database.BatchableContext bc, List<Lead> scope){
        for(Lead Leads : scope){
            Leads.LeadSource = 'Dreamforce';
        }
        update scope;
    }
    
    global void finish(Database.BatchableContext bc){
        
    }
}




@isTest
public class LeadProcessorTest {
    static testMethod void leadProcessorTrailTest(){
        List<Lead> leadList = new List<Lead>();
        for(integer i = 0; i<200; i++){
            Lead leads = new Lead();
            leads.FirstName = 'Ankit';
            leads.LastName = 'Avula'+i;
            leads.Company = 'ARG';
            leadList.add(leads);           
        }
        insert leadList;
        Test.startTest();
        LeadProcessor L = new LeadProcessor();
//l.execute(null,[select leadsource from lead]);
        Database.executeBatch(L);
        Test.stopTest();
    }

}
User-added image

I have created a permission set with the system permission "Two-Factor Authentication for User Interface Logins" and assigned it to the Samantha Cordero users. Here is the login history which i have used the Authenticator to authenticate the login of the user.

User-added image
What else am i missing? Any help is much appreciated.
global class LeadProcessor implements 
    Database.Batchable<Leads>, Database.Stateful {
//     Database.Batchable<Sobject>, Database.Stateful {

    
    // instance member to retain state across transactions
    global Integer recordsProcessed = 0;

    global Database.QueryLocator start(Database.BatchableContext bc) {
        return Database.getQueryLocator([Select LastName From Leads ]);

     }
          
    }

    global void execute(Database.BatchableContext bc, List<Leads> scope){
        // process each batch of records
        List<Leads> leads = new List<Leads>();
            for (Leads:leads) {
                Leads.LeadSource = Dreamforce;
                // add Leads to the list to be updated
                leads.add(leads);
                // increment the instance member counter
                recordsProcessed = recordsProcessed + 1;
            }
        }
        update leads;
    }    

    global void finish(Database.BatchableContext bc){
        System.debug(recordsProcessed + ' records processed. Shazam!');
        AsyncApexJob job = [SELECT Id, Status, NumberOfErrors, 
            JobItemsProcessed,
            TotalJobItems, CreatedBy.Email
            FROM AsyncApexJob
            WHERE Id = :bc.getJobId()];
        // call some utility to send email
        EmailUtils.sendMessage(a, recordsProcessed);
    }    

}