I am adding a new custom drop down field to contact. Options are YES Or No, The default value will be Yes. however I need all the old records to have the yes value as well. I tried to do it using workflow but old records wont be updated. I may be able to do it with trigger but I have never written one and not sure what I need or how to write one

1 Answer 1


You can do this by going to the Developer Console and writing a small piece of code to get what you want. Try it first in your sandbox please!

The Developer Console runs in system content and it will execute your logic, so be careful if you haven't used it before.

I don't know the name of your object so you need to change the object in your code.

for(List<Contact> conList :[SELECT Id, yourDropDownField__c FROM Contact])
  for(Contact ob: conList)
     ob.yourDropDownField__c ='Yes';
      update conList;

This way you can create chunks of 200 records and they will get updated with the new value.

I hope it helps!

  • Hi, thank you for the respond, so the object is Contact, so the List would be List<Contact>.. how does it know to do this 200 records at a time
    – Metawaa
    Mar 10, 2017 at 23:52
  • You don't need to worry about the 200 chunks, the system will run an iteration and do the job for you. Do you have more than 10.000 contacts? Mar 10, 2017 at 23:54
  • I dont think so
    – Metawaa
    Mar 10, 2017 at 23:56
  • Ok, them the code will take care of all Contacts. All you need to do is to add the correct field to the code above and run it. Make sure you try first in your sandbox to get the results you looking for. Good luck! Mar 10, 2017 at 23:57
  • 1
    You can go up to 50.000 records on the SOQL, more than that will reach governor limits. Mar 11, 2017 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .