You need to sign in to do that
Don't have an account?
shan876
Where did I got wrong?
Update a field based on another field??
Hi all:
I have a field "Site"... Now this field has to equal the same exact value that is in Status_Description which is a picklist. Now I have the following code that I try to write Obviously it is not working: Please help:
Code:
My Trigger trigger accountsiteupdate on Account (after update) { if (Trigger.isBefore){ Account[] accs=Trigger.new; acct_site_update.addacctsiteupdate(accs); } } My Class public class acct_site_update { // This class updates the Account Site field on //account records that are // passed to it. public static void addacctsiteupdate(Account[] accs) { for (Account a:accs) { if (a.Site != a.Account_Status_Description__c) { a.Site = a.Account_Status_Description__c; } } } }
Where did I got wrong?
Thanks
Shan
hi:
so I took the isbefore thing away and now I get this:
Apex script unhandled trigger exception by user/organization: 00550000000lxVc/00DT0000000Ec1z
accountsiteupdate: execution of AfterUpdate
caused by: System.Exception: Record is read-only
Class.acct_site_update.addacctsiteupdate: line 13, column 1
Trigger.accountsiteupdate: line 5, column 5
I know the record is not read-only... So I have no idea why is it stating that...
but let me ask something:
I need the trigger to fire off when a.Site is null or not matching the value from the Picklist Status_Description. This could happen during an insert of a new record or an update to an old record. So should I be using after insert,after update and should I use Trigger.new plus the Trigger.old...
I am sooo confused..
But thanks for helping me out
Shan