Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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
share|improve this question
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 Feb 20 at 23:18
add comment

2 Answers

up vote 1 down vote accepted

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

share|improve this answer
add comment

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();
share|improve this answer
    
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 Feb 22 at 18:13
    
No worries. Glad to help :) –  sfdc_ninja Feb 22 at 18:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.