• Pradhyumn Bansal
  • NEWBIE
  • 50 Points
  • Member since 2018

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 7
    Replies
Hello, can you please explain how to make a batch updating of records from one object?

The wrong way is to put the DML statement inside the for loop like this:
list<Account> accs = [Select Id, Name from Account];
for(Account acc :accs) {
acc.Name = 'test';
update acc;
}
This is also a wrong example because we can still exceed the governor limits of updating more than 50000 records at once:
 
list<Account> accs = [Select Id, Name from Account];
for(Account acc :accs) {
acc.Name = 'test';
}
update accs;

I heard that you can do a batch update of 300 records in a list so you don't exceed 50 000 records updated and also you don't hit the too many SOQL queries exception. How to do that though?
Hi all,
I have A custom object Goals__c and have a lookup of goals in contact standard object. When i am show the related List on Contacts Detail Page
I Want to Override the New Goals Button.
User-added image 
But i does not want to change my Goals__c Object new standard Button.
User-added image
is there any method to change redirection of VF page only on contact Goal__c  related list new Goals button. where as my Goal__c new button still set on standard VF page.
Hello, hoping you guys can help me with this. I've written an Apex trigger to auto-assign leads to accounts using a custom lookup relationship field. There are two "domain" fields on account which if a match is found with either of them, the lead should be auto assigned to account. But only if the lead is not already assigned to an account.

I wrote this trigger and it does work, but it keeps hitting limits and failing... not sure how it can be improved to avoid that.
 
trigger Assign_Leads_to_Account2 on Lead (before insert, before update) {

   List<String> LeadEmailDomains = new List<String>();
   Map<String, Id> matchingAcctDomain = new Map<String,Id>();

    for (Lead newLead : trigger.new){
        LeadEmailDomains.add(newLead.Email_Domain__c);
    }
    for(Account acct1 : [Select Id, Email_Domain__c from Account where Email_Domain__c IN : LeadEmailDomains]){
        matchingAcctDomain.put(acct1.Email_Domain__c, acct1.Id);
    }
    for(Account acct2 : [Select Id, Email_Domain_2__c from Account where Email_Domain_2__c IN : LeadEmailDomains]){
        matchingAcctDomain.put(acct2.Email_Domain_2__c, acct2.Id);
    }
    for (Lead newLead : trigger.new){
        if(newLead.account__c == null){
        newLead.Account__c = matchingAcctDomain.get(newLead.Email_Domain__c);
    }
    }

}

Any advice?
Hello, can you please explain how to make a batch updating of records from one object?

The wrong way is to put the DML statement inside the for loop like this:
list<Account> accs = [Select Id, Name from Account];
for(Account acc :accs) {
acc.Name = 'test';
update acc;
}
This is also a wrong example because we can still exceed the governor limits of updating more than 50000 records at once:
 
list<Account> accs = [Select Id, Name from Account];
for(Account acc :accs) {
acc.Name = 'test';
}
update accs;

I heard that you can do a batch update of 300 records in a list so you don't exceed 50 000 records updated and also you don't hit the too many SOQL queries exception. How to do that though?
Hi all,
I have A custom object Goals__c and have a lookup of goals in contact standard object. When i am show the related List on Contacts Detail Page
I Want to Override the New Goals Button.
User-added image 
But i does not want to change my Goals__c Object new standard Button.
User-added image
is there any method to change redirection of VF page only on contact Goal__c  related list new Goals button. where as my Goal__c new button still set on standard VF page.
Hi All,
Actally i have one custom field<Account_name__c > on custom object (Jibber__c).This field Account_name__c is master detail relationship having on Account.object.

Now i want dispaly readonly with value on visualforcepage. 

Kindly help me..Please see the below my screen shot 
User-added image

Thanks,
Chinni