function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bathybathy 

Prefill contact lookup field in new task edit page

Hi All,

We have a new requirement to prefill name field with Contact related to the object from where the new task is being created. I want this to be done globally.  Can this be achieved?

I have done URL hacking for two custom objects previously but now my users want this to happen every time they create a new task.

Any Ideas?
MissedCallMissedCall
Just a thought,

How about creating a visualforce page and override the standard new task button with this visualforce page?
Dominic SharpeDominic Sharpe
We have a custom button in our org that creates a new task and prepopulates the fields. The button uses URL hacking as well. We simply added

&tsk2={!Custom_Object__c.Contact__c}

to the url.

tsk2 is the "Name" field in the task

Custom_Object__c is the custom object

Contact__c is the custom lookup field to the Contact object.
bathybathy
MissedCall,

I thought the same thing, but how can we reference to parent object in the VF Page? it keeps changing for every object right?

Can you please include code for that if Possible?
Thanks,
bathybathy
Dominic,

Yeah I did the same for a custom object. Now my users want this from every object they create a new task. With this option,I will end up creating new Task button for every object. Is there any geenral refernce for parent object in URl Hacking?
MissedCallMissedCall
I may not be able to provide you any code snippet at this time, sorry. 

But here is the idea, when some one clicks the button you can focus on the page from where you are creating a task to capture the required information to be populated in your task. This could be achived using jQuery. 
bathybathy
Hi Missedcall,

Thanks for oyur idea. I dont have any knowledge of Jquery. Can you please help me out with code snippets or link to any documentation on Jquery?