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
syamkishore1.3906536981992773E12syamkishore1.3906536981992773E12 

Let's consider i have 10 records in some object.Let's take the name field.if change the name in one record all record's name field should be changed.Could anybody let me know how to do it?

Ramu_SFDCRamu_SFDC
Hi Syamkishore, you can achieve this using a trigger. However, you need to consider the situations like 1. when there are multiple records where the name is being changed it will be an issue. 2. if there are millions of records updating on all records is not optimal solution .

Below is the same code on how you can achieve this.

trigger Travel_Namechangeonall on travel__c (after update) {
    list<travel__c> travelrecstoupdate=new list<travel__c>();
list<travel__c> travels=new list<travel__c>([select id from travel__c]);
    string name=trigger.new[0].name;
    if(name!=trigger.old[0].name){
    for(travel__c travel1:travels){       
        travel1.name=name;
        travelrecstoupdate.add(travel1);
    }
    update travelrecstoupdate;
    }
}