I tried to write javascript custom convert lead button with validation. Everything is working as expected but in the last two cases, after converting the client, the user is redirected to the newly created account and users who use the console must return to it.
The question is how to convert the code below to recognize whether the action takes place in the console and opens a new tab or as before.
I can also assume that the action always takes place in the console. How should it look like in this case?
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")}
var Check = '{!JSENCODE(Lead.To_check__c)}';
var Date = '{!JSENCODE(TEXT(Lead.date_time_of_established_contact__c))}';
var Place = '{!JSENCODE(Lead.place_of_established_contact__c)}';
var Purpose = '{!JSENCODE(Lead.Purpose_of_the_meeting__c)}';
if(Check == 'Yes' && Date == '')
{alert('Field1 is empty');}
if(Check == 'Yes' && Place == '')
{alert('Field2 is empty');}
if(Check == 'Yes' && Purpose == '')
{alert('Field3 is empty');}
if(Check == 'No')
{window.parent.location.href="lead/leadconvert.jsp? retURL=%2F"+'{!Lead.Id}'+"&id="+'{!Lead.Id}';}
if(Check == 'Yes' && Place != '' && Date != '' && Purpose != '')
{window.parent.location.href="lead/leadconvert.jsp?retURL=%2F"+'{!Lead.Id}'+"&id="+'{!Lead.Id}';}