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
Amit Kr SinghAmit Kr Singh 

How to write trigger for copying custom field value to another standard field in a same object

In my current senarion

I want to trigger for   copying custom field    
accountspecification__c   value to another standard field  SicDesc   

in a same object (Account)  

Please help me.

Thanks In Advance
Best Answer chosen by Amit Kr Singh
RAM AnisettiRAM Anisetti
Hey use below code
 
trigger accountsamle on Account(before update,before insert){

 if(trigger.isInsert || trigger.isUpdate){

for(Account a:trigger.new){
//copying from custom field to std field
a.SicDesc =a.accountspecification__c;

}
}
}

 

All Answers

RAM AnisettiRAM Anisetti
Hey use below code
 
trigger accountsamle on Account(before update,before insert){

 if(trigger.isInsert || trigger.isUpdate){

for(Account a:trigger.new){
//copying from custom field to std field
a.SicDesc =a.accountspecification__c;

}
}
}

 
This was selected as the best answer
cloudSavvyProgcloudSavvyProg
Hi Amit,

You can do this using workflow rules.

 Here is doc for creating workflow.
https://help.salesforce.com/htviewhelpdoc?id=customize_wf.htm&siteLang=en_US


Use field action on workflow. Here is the doc to creating field action.
https://help.salesforce.com/HTViewHelpDoc?id=workflow_managing_field_updates.htm&language=en_US

Hope this helps.

Regards,
CloudSavvyProg
Pun!5h3rPun!5h3r
Hi Amit,
Create a formula field 'accountspecification' of Apprpriate DataType that you need(very few Options are available like Date,Currency,text,Number,percent,etc).

In step 3/5 : Set Just SicDesc in Formula, which is your Standard field (only SicDesc in Formula)

and its Done.... Easy and best

Regards,
Abdulrahim
Pun!5h3rPun!5h3r
Also Mark As best Reply
Amit Kr SinghAmit Kr Singh
Thanku So much  RAM Anisetti