I am building a custom button and I have this so far:
{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")}
var lead = new sforce.SObject("Lead");
lead.id = "{!Lead.Id}";
lead.OwnerId = "ID";
lead.Status = "STATUS";
var result = sforce.connection.update([lead]);
if (result[0].getBoolean("success"))
{
// Refresh window
window.location.reload();
}
else
{
alert("Error saving lead");
}
This all works perfectly and makes the changes I desire, but what I also want to happen is when the button is clicked, and before anything is saved, I want the:
lead.Reason__c
Text field to pop up, like it would if you double clicked it, so that the user can fill in a reason for clicking the button
I have tried code like:
lead.Reason__c.open
lead.Reason__c.edit
But have had no luck and am pretty much just stabbing in the dark with this.
I hope someone can help,
Thanks all
Since you only have one field, you do not need a form, I would recommend you use javascript’s prompt box and if it returns something other than null (null -> user clicked cancel) do your magic
PS: I would also recommend using a “fresher” ajax toolkit than 8.0 🙂 we are at 24.0 now. I doubt they’ll obsolete the old ones but you never know.