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
pradeep m 27pradeep m 27 

Error: Compile Error: unexpected token: 'map' at line 3 column 0


trigger StudentIdnew on Account (Before Insert) { 

 map<Account,Account Number> map1=trigger.newmap;

for(Account a : map1.values){

if(a.AccountNumber == null){
          a.AccountNumber = '12345';
         
          }     
           
 }
}
Amit Chaudhary 8Amit Chaudhary 8
Please try below code:-
Example 1:-
trigger StudentIdnew on Account (Before Insert) 
{ 
	map<Id,Account> map1= trigger.newmap;

	for(Account a : map1.values)
	{

		if(a.AccountNumber == null)
		{
				  a.AccountNumber = '12345';
		}     
	}
}

Example 2:-
 
trigger StudentIdnew on Account (Before Insert) 
{ 

	for(Account a : trigger.newmap.values)
	{

		if(a.AccountNumber == null)
		{
				  a.AccountNumber = '12345';
		}     
	}
}

Example 3:-
trigger StudentIdnew on Account (Before Insert) 
{ 

	for(Account a : Trigger.New)
	{
		if(a.AccountNumber == null)
		{
				  a.AccountNumber = '12345';
		}     
	}
}

Please mark this as solution if this will resolve your issue.
Thanks
Amit Chaudhary
Ajay K DubediAjay K Dubedi
Hi Pradeep...
Trigger.newMap - A map of IDs to the new versions of the sObject records.Note that this map is only available in before update, after insert, and after update triggers.
 
If not satisfied then can open this link : http://salesforceprasad.blogspot.in/2014/10/triggernewmap-and-triggeroldmap-in.html