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
mac adminmac admin 

custom Create Task button on custom object

Hi all,
I want to create a custom button in the list view that redirects to task create page along with selected record Id's. And create a task for the selected records in custom object.
Can we achive this ...?
Can anyone help me over here.

Thanks in advance.

regards,
mac.
Kiranpreet KaurKiranpreet Kaur
Yes you can do it by url hacking.

Just create a button and in url just write the following url.

https://na25.salesforce.com/00T/e?who_id={!Object.Id}&retURL=%2F00Q31000014vols

Keep coding......
mac adminmac admin
Hi Kiranpreet Kaur,
Thanks for reply, I'm not able to open th elink which you provided above.
Can you help me how we can achive this...?
Kiranpreet KaurKiranpreet Kaur
Just pass the object id in it like if you are creating  button in lead then

https://na25.salesforce.com/00T/e?who_id={!Lead.Id}&retURL=%2F00Q31000014vols

and if it is from account the use what id instead of whoid.
https://na25.salesforce.com/00T/e?what_id={!Account.Id}&retURL=%2F00Q31000014vols
mac adminmac admin
Hi Kiranpreet Kaur,
I'm trying for custom object not for Account or Lead.
Kiranpreet KaurKiranpreet Kaur
Hi mac admin,

It will also work for custom object. But before this you need to allow the activities feature for that cusom object.

To enable the feature, you need to choose " Allow Activities" in the Customer Object Definition (Setup =>Create => select custom object => Edit => Optional Feature => check "Allow Activities").

After this create a button in task object and make its Display Type as List button.

Say if your cusotm object name is abc__c than in  Button or Link URL wirte:

https://na25.salesforce.com/00T/e?what_id={!abc__c.Id}&retURL=%2F00Q31000014vols.

Go to the page layout button and make it visible form related list settings and use it.
mac adminmac admin
Hi Kiranpreet Kaur,
Does it works for multiple records...? or for only single record.....
mac adminmac admin
Hi Kiranpreet Kaur,
I have followed your steps but it throwing error.
The value of the "what_id" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. 

And also tried with an free app absi steps https://appexchange.salesforce.com/servlet/servlet.FileDownload?file=00P3000000P3foVEAR
after installing the app in my dev org, But it also throwing error as below

A problem with the OnClick JavaScript for this button or link was encountered:

unterminated string literal

 
Kiranpreet KaurKiranpreet Kaur
Just click the standard new button to create task from object related list.
Copy the url and replace the recordId(Value of what_Id) with {Obejct.Id} and place that url in button.
Scott DiehlScott Diehl
Thanks for the help on this ... it sort've worked.  Though, I'm in Lightning and it opens a Classic Task Window.  Is there any means to retain the Lightning display?