You need to sign in to do that
Don't have an account?
Keer Yenduri
trigger error
trigger Comparision on Account(before update)
{
for(Account acc : Trigger.new)
{
Account oldAccount = Trigger.oldMap.get(acc.ID)
if(acc.AccountNumber!=oldAccount.AccountNumber)
{
System.debug('Account number is changed');
System.debug('old account');
System.debug('new account');
acc.Type = 'prospect';
}
else
{
System.debug('number has not been changed');
acc.Type = 'other';
}
}
}
in this program i got this error like:
Compile Error: unexpected token: 'trigger' at line 1 column 0
{
for(Account acc : Trigger.new)
{
Account oldAccount = Trigger.oldMap.get(acc.ID)
if(acc.AccountNumber!=oldAccount.AccountNumber)
{
System.debug('Account number is changed');
System.debug('old account');
System.debug('new account');
acc.Type = 'prospect';
}
else
{
System.debug('number has not been changed');
acc.Type = 'other';
}
}
}
in this program i got this error like:
Compile Error: unexpected token: 'trigger' at line 1 column 0
Hi,
Are you trying to create a trigger by going to Apex classes section in your org by any chance ?
If so, please go to Setup -> Build -> Develop -> Apex Triggers and try creating.
Regards,
Lakshmi.
All Answers
Your trigger is fine but try this
again i got the same error
Hi,
Are you trying to create a trigger by going to Apex classes section in your org by any chance ?
If so, please go to Setup -> Build -> Develop -> Apex Triggers and try creating.
Regards,
Lakshmi.
solved my problem.
Thanks
"please go to Setup -> Build -> Develop -> Apex Triggers and try creating."
this is the best answer
but how can i find whether the trigger is fired or not.
please let me know.
To know whether the trigger has been fired or not, you can check if your debug statements are logged in the Debug log.
Check under -> Setup -> Monitor -> Logs -> Debug logs
Regards,
Lakshmi.
Thanks,
Keer