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
Aishwarya Rao 6Aishwarya Rao 6 

Account Trigger Issue: Loop variable must be of type Account

Hi Friends,
 Am trying to create a Trigger on Account object but am getting the Error as : Loop variable must be of type Account at line 4 column 14
 Can anyone give me a solution to the following code

 trigger accTrigger on Account(After Insert) {
 
 set<string> names  =  new set<string>();
 for(account acc : trigger.new) {
  }
}
Best Answer chosen by Aishwarya Rao 6
Arunkumar RArunkumar R
Hi,

There may be a chance to have a class Name as "Account", Rename that specfic class name, then try save your trigger. 

All Answers

Sachin KadianSachin Kadian
SO when are you getting this error?? when saving??
Aishwarya Rao 6Aishwarya Rao 6
Yes while saving it
Sachin KadianSachin Kadian
I dont see there is any error. I am able to save it. 
dillip nayak 3dillip nayak 3
HI 

I am trying your shared code its not giving me error.Can you please share the whole code where you getting the error.

User-added image
Aishwarya Rao 6Aishwarya Rao 6
User-added image
dillip nayak 3dillip nayak 3
HI

Just go devloper console write same code there 


trigger accTrigger on Account (before insert) {
set<string> names  =  new set<string>();
 for(account acc : trigger.new) {
     
     
  }
}
Aishwarya Rao 6Aishwarya Rao 6
User-added image
dillip nayak 3dillip nayak 3
just put Account like this 

for(Account acc:trigger.new) is it giving error 
Arunkumar RArunkumar R
Hi,

There may be a chance to have a class Name as "Account", Rename that specfic class name, then try save your trigger. 
This was selected as the best answer
dillip nayak 3dillip nayak 3
Yes Arunkumar  is right please check that same
Aishwarya Rao 6Aishwarya Rao 6
Thank you ArunKumar and Dilip nayak .The problem was with the class name.