+ Start a Discussion
Ashu3006Ashu3006 

Need Help On Trigger

 

Hi Everyone,

 

I am getting the following Err "" Compile Error: set must have exactly 1 type argument at line 1 column 1"

 

 

trigger Test123 on Lead(before insert, before update) {
        //Set<Id,Integer> ownerids=new Set<Id,Integer>();
        
        Set<Id> ownerids=new Set<Id>();
    
//reterving the owner id for the lead
for(Lead l : Trigger.new)
{
        Id ownerId=l.OwnerId;
        ownerids.add(ownerId);
    //User theower1=[SELECT Id, Region__c FROM User where Id = :l.OwnerId];
    //User theowner=[SELECT id,region__c FROM USER WHERE id=l.ownerId];u
}   
List<User> theower1=[SELECT Id, Region__c FROM User where Id IN:ownerids];
Map<Id.User> userownerlead=new Map<Id.User>(theower1);

    
    for(Lead l : Trigger.new)
        l.Region__c=theower1.Region__c;
         l.Region__c=userownerlead.get(l.OwnerId).Region__c;
         
}
}

 

Can u please what is going wroing in my code

thanks for help in advance

Best Answer chosen by Admin (Salesforce Developers) 
pujapuja

If you uncommented the following line 

 Set<Id,Integer> ownerids=new Set<Id,Integer>();

 

it gives error "Error: Compile Error: set must have exactly 1 type argument at line 1 column 1" because the set takes only one argument ,rather than set you take a map for this because map is work on the Key=value concept

All Answers

MandyKoolMandyKool

Hi,

 

on which line you are getting this error? Could you plz highlight the line.

 

looks like you tried to save the trigger when following line was uncommented

 

//Set<Id,Integer> ownerids=new Set<Id,Integer>();

 

 

pujapuja

If you uncommented the following line 

 Set<Id,Integer> ownerids=new Set<Id,Integer>();

 

it gives error "Error: Compile Error: set must have exactly 1 type argument at line 1 column 1" because the set takes only one argument ,rather than set you take a map for this because map is work on the Key=value concept

This was selected as the best answer
venkat-Dvenkat-D

Delete the below line from your code and youshould be good

 

//Set<Id,Integer> ownerids=new Set<Id,Integer>();

Ashu3006Ashu3006

The Modified code below by deleting  the Comment

 

 

trigger Test123 on Lead(before insert, before update) {


Set<Id> ownerids=new Set<Id>();

//reterving the owner id for the lead
for(Lead l : Trigger.new)
{
Id ownerId=l.OwnerId;
ownerids.add(ownerId);
//User theower1=[SELECT Id, Region__c FROM User where Id = :l.OwnerId];
//User theowner=[SELECT id,region__c FROM USER WHERE id=l.ownerId];u
}
List<User> theower1=[SELECT Id, Region__c FROM User where Id IN:ownerids];
Map<Id.User> userownerlead=new Map<Id.User>(theower1);


for(Lead l : Trigger.new)
l.Region__c=theower1.Region__c;
l.Region__c=userownerlead.get(l.OwnerId).Region__c;

}
}

 

But Still i am facing with the following Err"

Error: Compile Error: map must have exactly 2 type arguments at line 1 column 1"

Can u please helpme out how to Fix.

 

 

Regards

Anu

venkat-Dvenkat-D

Try the below code..

 

trigger Test123 on Lead(before insert, before update) {

Set<Id> ownerids=new Set<Id>();

//reterving the owner id for the lead
for(Lead l : Trigger.new)
{

ownerids.add(l.ownerId);

}

Map<Id.User> userownerlead=new Map<Id.User>([SELECT Id, Region__c FROM User where Id IN:ownerids]);
for(Lead l : Trigger.new)
//l.Region__c=theower1.Region__c;
l.Region__c=userownerlead.get(l.OwnerId).Region__c;

}
}

 

If it solves your problem, mark it as solution.

Ashu3006Ashu3006

HI All,

 

I am stilling facing the issue .I have Done the changes to the code which you have sent.

 

But No Luck.Can u pl help me out

 

Regards

Anu

frederic baudaxfrederic baudax

Hi,

 

Problem with that error msg is that it doesn't point to the affected line.

 

While quickly reading your code

 

Map<Id.User> userownerlead=new Map<Id.User>([SELECT Id, Region__c FROM User where Id IN:ownerids]);

 

 

Just a wild guess, i'de say it should be coma separated instead of a point  : Id,User

 

Kr,

Fred

kjh3185kjh3185

I just had the same problem.  This error message fires when you improperly define a map.  Look for all places within a method where you've defined a map and make sure each has two arguments separated by a comma.