You need to sign in to do that
Don't have an account?
Help with OnClick JavaScript Button
I am trying to build a javascript button, which when clicked will perform a different action dependant upon the content of a custom field in Salesforce. It seems to be defaulting to the first "IF" statement regardless of what is entered into the field, unless the field is blank. If the field is blank I receive an error message, not the "ELSE" statement.
Thank for looking at this. I have already posted in the Saleforce forums and will hopefully get a reply soon. This is my first attempt with Javascript and I am not certain I hit all my marks.
I have discovered by changing the "ELSE IFs" to "IF" will default to the last entry, not the first. Below is the code. Thank you in advance for your assistance.
if ({!Lead.Description}= "onlinereg")
{
window.location = "/lead/leadconvert.jsp?IsReminderSet_fu=0&nooppti=1&id={!Lead.Id}&RetURL=/{!Lead.Id}";
}
else if ({!Lead.Description}= "onlineCEUreg")
{
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=CEU%20Order";
}
else if ({!Lead.Description}= "renewbyexam")
{
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=Renewal%20by%20Exam";
}
else if ({!Lead.Description}= "renewbyCEU")
{
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=Renewal by CEU";
}
else
{
alert("This lead can not be marked as paid.");
}
Few tweeks required... highlighted in red
if ("{!Lead.Description}" == "onlinereg")
{
window.location = "/lead/leadconvert.jsp?IsReminderSet_fu=0&nooppti=1&id={!Lead.Id}&RetURL=/{!Lead.Id}";
}
else if ("{!Lead.Description}" == "onlineCEUreg")
{
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=CEU%20Order";
}
else if ("{!Lead.Description}" == "renewbyexam")
{
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=Renewal%20by%20Exam";
}
else if ("{!Lead.Description}" == "renewbyCEU")
{
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=Renewal by CEU";
}
else
{
alert("This lead can not be marked as paid.");
}
All Answers
Few tweeks required... highlighted in red
if ("{!Lead.Description}" == "onlinereg")
{
window.location = "/lead/leadconvert.jsp?IsReminderSet_fu=0&nooppti=1&id={!Lead.Id}&RetURL=/{!Lead.Id}";
}
else if ("{!Lead.Description}" == "onlineCEUreg")
{
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=CEU%20Order";
}
else if ("{!Lead.Description}" == "renewbyexam")
{
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=Renewal%20by%20Exam";
}
else if ("{!Lead.Description}" == "renewbyCEU")
{
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=Renewal by CEU";
}
else
{
alert("This lead can not be marked as paid.");
}
That's it! Thank you for the help!