You need to sign in to do that
Don't have an account?
Itayb34
Custom Button Using Javascript
Hello
I have a general question regard Javascript in custom button. I want that the user will get an error message if a field is blank on the lead layout (in this case - company type).
The code below is working, just wanted to understand if "REQUIRESCRIPT" section is needed (connection and apex rows)
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/26.0/apex.js")} var leadObj = new sforce.SObject("Lead"); leadObj.Id = '{!Lead.Id}'; var type = "{!Lead.Company_Type__c}"; if (type == "") { alert("Please enter company type before converting this lead"); } else{ var result = sforce.connection.update([leadObj]); window.location.href = "/lead/leadconvert.jsp?retURL=%2F{!Lead.Id}&id={!Lead.Id}"; }
Thanks!
Itay
Hi Italy,
Yes the Requirescripts are necessary.
The sforce object that you have used in the code is not available in javascript. This is available through these included libraries.
Thanks