You cannot reference polymorphic lookup fields (WhoId & WhatId) in a formula because they could be pointing to one of many possible entities.
You will need a before insert, before update trigger to query for those WhoIds, query for the Mobile and then set it.
Trigger TaskBefore on Task(before insert, before update){
Map<Id, List<Task>> whoIds = new Map<Id, List<Task>>{};
For (Task t : trigger.new)
If(t.WhoId != null){
List<Task> tasks = whoIds.get(t.WhoId); //this should be t.WhoId (not task.WhoId)
If (tasks == null){
tasks = new List<Task>{};
whoIds.put(t.WhoId, tasks);
}
tasks.add(t);
}
For (Lead ld : [Select Id, Name, Mobile from lead where Id in :whoIDs.keySet()])
For(Task t : whoIds.get(ld.id))
t.Mobile__c = ld.Mobile;
For(Contact con : [Select Id, Name, Mobile from Contact where Id in :whoIds.keySet()])
For(Task t : whoIds.get(con.id))
t.Mobile__c = con.Mobile;
}
OwnerId
which can point to User or Queue) don't work nicely with formulas. Salesforce will let you use only fields that surely exist on all possible lookup targets - pretty much onlyId
andName
. So some coding solution will be needed - either trigger as @MohithKumar suggests or some field prepopulation in the new Task's URL...