function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ritika SinghRitika Singh 

How to update field value for all existing records of an object ?

There's an custom object "Student" and 
Field 1 :  Subject
Field 2  :  Branch
Current Scenario - Subject = Maths, Social, English, Arts
Branch(Multi picklist)  - Science , Humanities, Commerce

Requirement :
Given : Subject - Maths & Branch - Humanities
TODO : For all picklist field with value Branch = Humanities,
 Change Field value of Subject from Maths to English for all existing records in object.

What is the best possible way to achieve this by configuration ?
Best Answer chosen by Ritika Singh
ShirishaShirisha (Salesforce Developers) 
Hi Ritika,

You can achieve this by using the process builder but the field gets updated whenever we edit/create the record only.In order to update all the existing record you would need to edit and save all the record which need manual effort.

So,I would suggest you to go with the batch class to achieve the same.

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi Ritika,

Greetings!

You can go with the batch apex to achieve this since you are trying to update all existing records based on the value of Brach field.

Reference:https://www.forcetalks.com/salesforce-topic/writing-a-batch-apex-to-update-field/

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Ritika SinghRitika Singh
Hi Shirisha,

Thanks for quick response ! Can we achieve the above scenario BY using any configuration technique in salesforce inspite customizing using batch class ?
ShirishaShirisha (Salesforce Developers) 
Hi Ritika,

You can achieve this by using the process builder but the field gets updated whenever we edit/create the record only.In order to update all the existing record you would need to edit and save all the record which need manual effort.

So,I would suggest you to go with the batch class to achieve the same.

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
This was selected as the best answer
Derek SchoonmakerDerek Schoonmaker
Hi Ritika,

One way you can update all records is by using a schedule-triggered flow. This is usually a better option if you don't have a large amount of records you want to update. 

Set the conditions as narrow as you can.

For your scenario, you can set the conditions
Object: Student
Conditions: Branch = Humanities
You must set the time in the future from when you activate the flow

Update Element = update subject to English

Hope this helps!