You need to sign in to do that
Don't have an account?
SFDC Coder 8
Trigger to update from Task to Contact
Hi All,
I have written a Trigger to update from Task to Contact,
This is my trigger
When I am updating Task record I am getting System.NullPointerException: Attempt to de-reference a null object: error.
Please tell me what changes need to be don.
Thanks in Advance
I have written a Trigger to update from Task to Contact,
This is my trigger
trigger updateTask on Task (after update) { List<Id> tsIds = new List<Id>(); for(Task ts : trigger.new){ tsIds.add(ts.WhoId); } Map<ID, Task> mapAccounts = new Map<ID, Task>([SELECT Id, F1__c from Task where Id IN :tsIds]); if(Trigger.isUpdate){ List<Contact> lstCon = [SELECT Id, name, CF1__c,AccountId FROM Contact where AccountId IN :tsIds]; For(Contact con : lstCon) { Task ts = mapAccounts.get(con.AccountId); con.CF1__c= ts.F1__c; } update lstCon; } }
When I am updating Task record I am getting System.NullPointerException: Attempt to de-reference a null object: error.
Please tell me what changes need to be don.
Thanks in Advance
From line no: 18 you are getting the Null Pointer Exception. And your code is written wrong.
1). Whoid contains only lead and ContactId.
Can you please suggest me what changes need to be done?