You need to sign in to do that
Don't have an account?
Sreenu Reddy 16
Method does not exist or incorrect signature: void put(Decimal, String) from the type Map<Id,String> at line 8 column 24
sfdc flocks can you give me help on below code .
Method does not exist or incorrect signature: void put(Decimal, String) from the type Map<Id,String> at line 8 column 24
trigger changeowner on Lead (before insert) {
Map<Id,String> zipCodeUserMap = new Map<Id,String>();
List<Zip_Code__c> zipCodes = new List<Zip_Code__c>();
zipCodes = [Select id,ZipCode__c,Counserlor__c from Zip_Code__c];
for (Zip_Code__c zc :zipCodes){
zipCodeUserMap.put(zc.ZipCode__c,zc.Counserlor__c);
}
for(Lead l : Trigger.new)
{
if(zipCodeUserMap.containsKey(l.Zip_Code__c))
{
l.Ownerid = zipCodeUserMap.get(l.Zip_Code__c);
}
}
}
Method does not exist or incorrect signature: void put(Decimal, String) from the type Map<Id,String> at line 8 column 24
trigger changeowner on Lead (before insert) {
Map<Id,String> zipCodeUserMap = new Map<Id,String>();
List<Zip_Code__c> zipCodes = new List<Zip_Code__c>();
zipCodes = [Select id,ZipCode__c,Counserlor__c from Zip_Code__c];
for (Zip_Code__c zc :zipCodes){
zipCodeUserMap.put(zc.ZipCode__c,zc.Counserlor__c);
}
for(Lead l : Trigger.new)
{
if(zipCodeUserMap.containsKey(l.Zip_Code__c))
{
l.Ownerid = zipCodeUserMap.get(l.Zip_Code__c);
}
}
}
Try this trigger:
trigger changeowner on Lead (before insert) {
Map<String, Id> zipCodeUserMap = new Map<String, Id>();
List<Zip_Code__c> zipCodes = new List<Zip_Code__c>();
zipCodes = [Select id, ZipCode__c, Counserlor__c from Zip_Code__c WHERE ZipCode__c != null AND Counserlor__c != null];
if(zipCodes.size() > 0) {
for (Zip_Code__c zc : zipCodes) {
zipCodeUserMap.put(String.ValueOf(zc.ZipCode__c), Id.ValueOf(zc.Counserlor__c));
}
for(Lead l : Trigger.new)
{
if(zipCodeUserMap.containsKey(l.Zip_Code__c))
{
l.Ownerid = zipCodeUserMap.get(l.Zip_Code__c);
}
}
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
All Answers
Try this trigger:
trigger changeowner on Lead (before insert) {
Map<String, Id> zipCodeUserMap = new Map<String, Id>();
List<Zip_Code__c> zipCodes = new List<Zip_Code__c>();
zipCodes = [Select id, ZipCode__c, Counserlor__c from Zip_Code__c WHERE ZipCode__c != null AND Counserlor__c != null];
if(zipCodes.size() > 0) {
for (Zip_Code__c zc : zipCodes) {
zipCodeUserMap.put(String.ValueOf(zc.ZipCode__c), Id.ValueOf(zc.Counserlor__c));
}
for(Lead l : Trigger.new)
{
if(zipCodeUserMap.containsKey(l.Zip_Code__c))
{
l.Ownerid = zipCodeUserMap.get(l.Zip_Code__c);
}
}
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
You create a map 'Map<Id, String>' but you put (Decimal, String) into this map that's why it throws an error.
I make some changes in your code. So try the following code it may be helpful for you:
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
I getting Variable does not exist: Zip_Code__c. I have tryed Variable " ZipCode__c" also . can you give best solution why it is getting like this error .
Thanks,
Srini..