You need to sign in to do that
Don't have an account?
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
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
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>();
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
Delete the below line from your code and youshould be good
//Set<Id,Integer> ownerids=new Set<Id,Integer>();
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
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.
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
Hi,
Problem with that error msg is that it doesn't point to the affected line.
While quickly reading your code
Just a wild guess, i'de say it should be coma separated instead of a point : Id,User
Kr,
Fred
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.