Salesforce custom button with the javascript is a very exciting feature to implement. We received a requirement from our customer for converting Leads. User should convert Lead record only if the status is changed to "Qualified". Typically when a lead is converted, Salesforce automatically changes the lead status to Qualified. But there are some custom validation rules created for lead record which doesn't allow to complete the conversion process and display error message as validation rules on lead page are not fulfilled.
I created a custom "Convert" button with the help of Javascript and replaced with standard button on lead page layout. The javascript validates whether lead status is qualified or not and doesn't allow user to proceed if it is not qualified.
Code:
Error Message:
I created a custom "Convert" button with the help of Javascript and replaced with standard button on lead page layout. The javascript validates whether lead status is qualified or not and doesn't allow user to proceed if it is not qualified.
Code:
var status = "{!Lead.Status}";
if (status == "Qualified")
{
window.location = 'https://ap1.salesforce.com/lead/leadconvert.jsp?retURL=%2F{!Lead.Id}&id={!Lead.Id}';
}
else
{
alert('Please change the Lead Status to Qualified then click on convert');
}
Error Message:
3 comments:
Hi Is there any idea how to get selected value of picklist from Account object in javascript.
The first line itself is getting a picklist value from Lead object to javascript.
For account you have to change the code
E.g.
var status = "{!Account.type}";
Hi Pranav, Thanks alot , Actually I tried it but it was not working , I tried to alert the value and the alert didnt come.
But today I found it is working, may be I did some mistake or typo. Thanks alot for your quick reply it got worked for me .
Regards,
Kishor
Post a Comment