• Yuvraj Programmer
  • NEWBIE
  • 10 Points
  • Member since 2015

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

I am new to batch class. Just wondering why we are using global access modifier instead of public. By referring to many developer forums, global is used to access the batch class outside the application whereas public used inside the application.. I see many blogs are giving example with global class eventhough Salesforce blogs too. 

Below code I used to coding practice for batch class:
 
public class AccoutBatchProcess implements Database.Batchable<Sobject>{
    
    public database.QueryLocator start(Database.BatchableContext ctx){
        return database.getQueryLocator('SELECT ID FROM Account');
    }
    
    public void execute(Database.BatchableContext ctx, List<Sobject> sList){
        
    }
    public void finish(Database.BatchableContext ctx){
        
    }
    
}
Is that mandatory that need to be replace global with public? Is that best practice to define the batch class as global?
 
I have created the account trigger to complete the trailhead task. But I'm facing following error:
Error:
Challenge Not yet complete... here's what's wrong: 
Setting 'Match_Billing_Address__c' to false updated the records anyway. The trigger should only act when Match_Billing_Address__c is true.


Trigger code:
trigger AccountAddressTrigger on Account (before insert, before update) {

    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c == true) {
            a.ShippingPostalCode = a.BillingPostalCode;
        }   
    }

}

Anyone please guide me which part I missed? Thanks in advance.
Hi All,

I am new to batch class. Just wondering why we are using global access modifier instead of public. By referring to many developer forums, global is used to access the batch class outside the application whereas public used inside the application.. I see many blogs are giving example with global class eventhough Salesforce blogs too. 

Below code I used to coding practice for batch class:
 
public class AccoutBatchProcess implements Database.Batchable<Sobject>{
    
    public database.QueryLocator start(Database.BatchableContext ctx){
        return database.getQueryLocator('SELECT ID FROM Account');
    }
    
    public void execute(Database.BatchableContext ctx, List<Sobject> sList){
        
    }
    public void finish(Database.BatchableContext ctx){
        
    }
    
}
Is that mandatory that need to be replace global with public? Is that best practice to define the batch class as global?
 
I have created the account trigger to complete the trailhead task. But I'm facing following error:
Error:
Challenge Not yet complete... here's what's wrong: 
Setting 'Match_Billing_Address__c' to false updated the records anyway. The trigger should only act when Match_Billing_Address__c is true.


Trigger code:
trigger AccountAddressTrigger on Account (before insert, before update) {

    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c == true) {
            a.ShippingPostalCode = a.BillingPostalCode;
        }   
    }

}

Anyone please guide me which part I missed? Thanks in advance.
When attempting to create my Apex trigger for this Trailhead development exercise, I receive an error. I don't understand how this is possible, because the records haven't been updated, and still aren't updating.
"Challenge not yet complete... here's what's wrong:
Setting 'Match_Billing_Address__c' to false updated the records anyway. The trigger should only act when Match_Billing_Address__c is true."


Here's my code:
trigger AccountAddressTrigger on Account (before insert, before update) {

    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c = true) {
            a.ShippingPostalCode = a.BillingPostalCode;
        }   
    }

}