You need to sign in to do that
Don't have an account?
shakila G
Error: Compile Error: Invalid identifier ''. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 12 column 23
Hi All,
Am trying to auto Populate the Task WhatID lookup Based Contact Lookup.
Am getting Following Error:
Error: Compile Error: Invalid identifier ''. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 12 column 23
Kindly let me know what I have to do here?
This is my Trigger.
trigger populateAccount on task (before insert, before update)
{
Set<ID> setConIds = new Set<ID>();
for(task obj : trigger.new)
{
if(obj.whoid!= null)
setConIds.add(obj.Whoid);
}
MAP<ID,Contact> mapCon =
new MAP<ID,Contact>([Select Account_name__C from Contact where id in: setConIds]);
for(Task obj : trigger.new)
{
if(obj.Whoid!= null)
{
Contact c = mapCon.add(obj.WhoiD);
obj.WhatID= c.Account_name__C;
}
}
Am trying to auto Populate the Task WhatID lookup Based Contact Lookup.
Am getting Following Error:
Error: Compile Error: Invalid identifier ''. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 12 column 23
Kindly let me know what I have to do here?
This is my Trigger.
trigger populateAccount on task (before insert, before update)
{
Set<ID> setConIds = new Set<ID>();
for(task obj : trigger.new)
{
if(obj.whoid!= null)
setConIds.add(obj.Whoid);
}
MAP<ID,Contact> mapCon =
new MAP<ID,Contact>([Select Account_name__C from Contact where id in: setConIds]);
for(Task obj : trigger.new)
{
if(obj.Whoid!= null)
{
Contact c = mapCon.add(obj.WhoiD);
obj.WhatID= c.Account_name__C;
}
}
trigger populateAccount on Task (before insert){
Set<Id> setConIds = new Set<Id>();
for(Task obj : trigger.new)
{
if(obj.whoId!= null)
setConIds.add(obj.Whoid);
}
Map<Id,Contact> mapCon =new Map<Id,Contact>([Select Account_name__c from Contact where id IN: setConIds]);
for(Task obj : trigger.new)
{
if(obj.Whoid!= null)
{
Contact con= mapCon.add(obj.whoId);
obj.WhatID= con.Account_name__c;
}
}
}
HI shakila G ,
your problem is slove
thanks
Thanks for the reply am getting following error.
While Executing the below trigger
trigger Autopopulate on task (Before insert){
Set<ID> setConId = new Set<ID>();
for(Task obj : Trigger.New){
If(Trigger.Isinsert) {
if(obj.Whoid !=''){
setConId.add(obj.Whoid);
system.debug('****setConId'+setConId);
}
}
if(Trigger.isupdate && obj.Whoid !='') {
if(obj.Whoid !=Null){
setConId.add(obj.Whoid);
system.debug('****setConId'+setConId);
}
}
}
list<contact> lsc=[Select ID,Account_name__C from Contact where id in:setConId];
map <ID, Contact> contactMap= new map <ID, Contact>();
for(Contact ct: lsc) {
contactMap.put(ct.Account_name__C , ct);
}
for(task obj : Trigger.New)
{
if(obj.Whoid!= null)
{
obj.WhatID= contactMap.get(obj.whoid ).Account_name__C ;
}
}
}