You need to sign in to do that
Don't have an account?
How to convert custom button with java script from classic view to lightning experience??
Hi,
I have a custom button in my salesforce classic with javascript code to redirect to VF page and some validations. This button will not work in lightning experience. How can i convert this button to wotk with lightning experience? Please help.
Below is my code..
{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")}
var a = (sforce.connection.query(
"Select Id, MSA_Status__c, Apts_MA_Type__c, APTS_isAddress_Validated__c, MSA_Date_of_Expiration__c, APTS_Has_Perpetual_MA__c, D_O_N_S__c " +
"from Account " +
"where id='{! Opportunity.AccountId}'").getArray("records")[0]);
var b = (sforce.connection.query(
"Select Id, IsPrimary, OpportunityId " +
"from OpportunityContactRole " +
"where OpportunityId ='{!Opportunity.Id}' AND IsPrimary = true ").getArray("records")[0]);
if({!NOT(ISPICKVAL(Opportunity.Contract_Renewal_Type__c,"AutoRenewal"))}&&{!NOT(ISPICKVAL(Opportunity.Contract_Renewal_Type__c,"AutoRenewal - Custom"))}&& {!NOT(ISPICKVAL(Opportunity.Contract_Renewal_Type__c,"Partial AutoRenewal"))}||
{!Opportunity.Vital_Indicator_Oppty2__c=="Exempt from quote block"}||
({!NOT(ISPICKVAL(Opportunity.Autorenewal_Status__c,"In Force"))}&&{!NOT(ISPICKVAL(Opportunity.Autorenewal_Status__c,"Rescinded"))}&&{!NOT(ISPICKVAL(Opportunity.Autorenewal_Status__c,"Cancellation Declined"))}||{!Opportunity.Vital_Indicator_Oppty2__c=="Exempt from quote block"}))
{
if({!ISPICKVAL( Opportunity.StageName , "4. Solution Definition")}||{!ISPICKVAL( Opportunity.StageName , "5. Proposal")}||{!ISPICKVAL( Opportunity.StageName , "6. Negotiation & Closing")})
{
if(a.D_U_N_S__c != null)
{
if( a.APTS_isAddress_Validated__c> 0 )
{
if((a.Apts_MA_Type__c!="NetProspex")&&(({!CONTAINS( $Setup.APTS_MSA_Create__c.Agreement_Types__c , TEXT( Opportunity.Agreement_Type__c ) )}&&{!NOT(ISBLANK(TEXT(Opportunity.Agreement_Type__c)))}&&{!CONTAINS(Opportunity.Channel_Identifier__c,"NA")})||{!Opportunity.APTS_Is_Valid_Apttus_Product__c}))
{
if(typeof b!=="undefined")
{
var acclocation, blnNoContact;
var acclocationsArray = sforce.connection.query(
"Select Id, APTS_Country_ISO_Code__c, APTS_State_ISO_Code__c, APTS_Billing_Contact__c, Apttus_Config2__IsDefault__c from Apttus_Config2__AccountLocation__c " +
"where Apttus_Config2__AccountId__c='{!Opportunity.AccountId}' " +
"AND APTS_isAddress_Validated__c = TRUE").getArray("records");
for(var i=0; i< acclocationsArray.length; i++) {
if( acclocationsArray[i].Apttus_Config2__IsDefault__c )
var acclocation = acclocationsArray[i];
if( acclocationsArray[i].APTS_Billing_Contact__c == null )
blnNoContact = true;
}
if( acclocation.APTS_Country_ISO_Code__c == null || acclocation.APTS_State_ISO_Code__c == null )
{
alert("Please verify default account location record as it does not have ISO Codes for Country or State.");
}
else if( blnNoContact )
{
alert("Please ensure that all valid Account Locations have Contact.");
}
else
{
window.open("/apex/Apttus_Proposal__OpportunityProposalCreate?id="+'{!Opportunity.Id}',"_self");
}
}
else
{
alert("Please add a Primary Contact to this Opportunity before creating a Proposal.");
}
}
else if((!({!CONTAINS( $Setup.APTS_MSA_Create__c.Agreement_Types__c , TEXT( Opportunity.Agreement_Type__c ) )})&&{!NOT(ISBLANK(TEXT(Opportunity.Agreement_Type__c)))})||{!NOT( Opportunity.APTS_Is_Valid_Apttus_Product__c )})
{
window.open('{!URLFOR($Action.cmgtQuote__c.New,null,[CF00N30000002Bott=Opportunity.Name,CF00N30000002Bott_lkid=Opportunity.Id,retURL='/'+Opportunity.Id],false)}',"_self");
}
}
else
{
alert("Please create default account location with valid address for this account by clicking on the Account Name and then scroll to Account Location section!");
}
}
else
{
alert("Please enter a valid DONS number on the Account record. If you do not know the DONS number, enter 9 zeros");
}
}
else
{
alert("Quote can be created only for opportunities between stage 4 and 6.");
}
}
else
{
alert ("You have attempted to create a quote on an opportunity marked as an autorenewal. Quote creation is not permitted due to autorenewal status. Please submit an Autorenewal Exception type Sales Operation case to have that modified.");
}