5

I have a url custom button on the Lead and Contact record. It creates a completed task on that record. However, I would like it so that when I click on the button, called "Log a Visit", the screen simply reloads instead of taking me to the Task page to save. Is this possible without using Visualforce?

Below is the button details for the Lead record:

/00T/e?&
retURL=%2F{!Lead.Id}&
cancelURL=%2F{!Lead.Id}&
who_id={!Lead.Id}&
followup=1&
tsk5=Walk-In Visit&
00Ni000000DFMc3=Lead
1
  • 1
    do you want a task to be created related to a lead with no data entry and no visualforce?You can go ajax route its not visualforce but definitely coding is involved
    – Rao
    Commented Feb 20, 2014 at 23:18

2 Answers 2

2

There is a way to do it with a URL hack by adding &save=1 to the button if you have disable some CSRF protection in your org. It is better to use the AJAX toolkit as sfdc_ninja answered. See this help article: http://help.salesforce.com/apex/HTViewSolution?id=000176169&language=en_US

5

Create a button with Behavior of 'Execute Javascript', and content source of 'OnClick Javascript'

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

  var myTask = new sforce.SObject("Task");
  myTask.WhoId = "{!Lead.Id}";
  myTask.Subject = "Walk-In-Visit ";
  sforce.connection.create([myTask]);
  window.location.reload();
2
  • That worked beautifully. Thanks a ton. I just added the last bit - myTask.Status = "Completed"; - to complete the task but I appreciate the response. And for the quick AJAX tutorial.
    – user6966
    Commented Feb 22, 2014 at 18:13
  • No worries. Glad to help :) Commented Feb 22, 2014 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .