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
sumit pawarsumit pawar 

how to get value of one field to another field on existing records?

here a small requirement i having..

i having contacts.. and default description field in contact object...(Populated)
now i created another description1 textarea field in contact object..

i want to add contents of description field in description1 field.

what i do Please suggest?
Vinit_KumarVinit_Kumar
create a before insert or before update trigger on Contact object and the Trigger should be something like below :-
Trigger updateDescription1 on Contact(before insert,before update)
{
for(Contact con : trigger.new)
{
if(con.description__c!=null && con.description!=trigger.oldMap(con.id).description__c)
{  
       con.decription__c = con.description1__c;//replace the API name of field
}
}
}

If this helps,please mark it as best answer to help others :)
sumit pawarsumit pawar
hey vinit,

what we doing in below statement?

con.description!=trigger.oldMap(con.id).description__c
Vinit_KumarVinit_Kumar
We are checking if old value or new value is different or not ....
Vinit_KumarVinit_Kumar
The line is 

con.description__c!=trigger.oldMap(con.id).description__c