You need to sign in to do that
Don't have an account?
cjen
convert javascript button to lightning
Hi, we wnat to migrate to lightning but one of our issues is the use of javascript and validation. Can anyone show be how to get a button or action in Lighting for the following? I have read articles, but we validate fields with javascript and also determine what kind of record to create based on picklist selection. Please help if possible, thanks!
if('{!Opportunity.Related_Contract__c}'!=''&&'{!Opportunity.Type_of_Contract__c}' != 'Addendum'){
alert("Sorry, a Contract record has already been created for this opportunity. You can view the Contract by clicking on the Related Contract link in the Contract/Amendment Details section.");
}
else if('{!Opportunity.Related_Amendment__c}'!=''&&'{!Opportunity.Type_of_Contract__c}' == 'Addendum'){
alert("Sorry, an Amendment record has already been created for this opportunity. You can view the Amendment by clicking on the Related Amendment link in the Contract/Amendment Details section.");
}
else if('{!Opportunity.Type_of_Contract__c}' == ''){
alert("Please enter a Type of Contract before requesting a Contract or Addendum.");
}
else if('{!Opportunity.Contact__c}' == ''){
alert("Please enter a Contract Contact before requesting a Contract or Addendum.");
}
else if(!('{!Opportunity.Type_of_Contract__c}'=='')&&'{!Opportunity.Has_Banker_PPE_Service__c}'>0&&('{!Opportunity.Cost_Per_Additional_User__c}'==''||'{!Opportunity.Users__c}'=='')){
alert("This opportunity has a Banker PPE service. Before requesting a Contract or Addendum, please provide the number of Users and the Cost per Additional User in the Contract Details section.");
}
else if('{!Opportunity.Type_of_Contract__c}' == 'Addendum'){
window.open ( "/a4u/e?saveURL={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}&00N38000003rUFs={!Opportunity.Name}&CF00N38000003rUFn={!Opportunity.Name}&CF00N38000003rUFn_lkid={!Opportunity.Id}&CF00N38000003rUFd={!Opportunity.Related_Contract__c}&CF00N38000003rUFd_lkid={!Opportunity.Related_ContractId__c}","_top");
}
else{
window.open ( "/800/e?saveURL={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}&00N38000003Hm3a={!Opportunity.Type_of_Contract__c}&Name={!Opportunity.Name}&ctrc40={!Opportunity.Contract_Term__c}&00N38000003Hj9L={!Opportunity.Renewal_Term_months__c}&00N38000003Hm4E=1&CF00N50000002bj33={!Opportunity.Name}&CF00N50000002bj33_lkid={!Opportunity.Id}&ctrc15=New&ctrc7={!URLENCODE(Opportunity.Account_Name_TEXT__c) }&ctrc7_lkid={!Opportunity.AccountId}","_top");
}
if('{!Opportunity.Related_Contract__c}'!=''&&'{!Opportunity.Type_of_Contract__c}' != 'Addendum'){
alert("Sorry, a Contract record has already been created for this opportunity. You can view the Contract by clicking on the Related Contract link in the Contract/Amendment Details section.");
}
else if('{!Opportunity.Related_Amendment__c}'!=''&&'{!Opportunity.Type_of_Contract__c}' == 'Addendum'){
alert("Sorry, an Amendment record has already been created for this opportunity. You can view the Amendment by clicking on the Related Amendment link in the Contract/Amendment Details section.");
}
else if('{!Opportunity.Type_of_Contract__c}' == ''){
alert("Please enter a Type of Contract before requesting a Contract or Addendum.");
}
else if('{!Opportunity.Contact__c}' == ''){
alert("Please enter a Contract Contact before requesting a Contract or Addendum.");
}
else if(!('{!Opportunity.Type_of_Contract__c}'=='')&&'{!Opportunity.Has_Banker_PPE_Service__c}'>0&&('{!Opportunity.Cost_Per_Additional_User__c}'==''||'{!Opportunity.Users__c}'=='')){
alert("This opportunity has a Banker PPE service. Before requesting a Contract or Addendum, please provide the number of Users and the Cost per Additional User in the Contract Details section.");
}
else if('{!Opportunity.Type_of_Contract__c}' == 'Addendum'){
window.open ( "/a4u/e?saveURL={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}&00N38000003rUFs={!Opportunity.Name}&CF00N38000003rUFn={!Opportunity.Name}&CF00N38000003rUFn_lkid={!Opportunity.Id}&CF00N38000003rUFd={!Opportunity.Related_Contract__c}&CF00N38000003rUFd_lkid={!Opportunity.Related_ContractId__c}","_top");
}
else{
window.open ( "/800/e?saveURL={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}&00N38000003Hm3a={!Opportunity.Type_of_Contract__c}&Name={!Opportunity.Name}&ctrc40={!Opportunity.Contract_Term__c}&00N38000003Hj9L={!Opportunity.Renewal_Term_months__c}&00N38000003Hm4E=1&CF00N50000002bj33={!Opportunity.Name}&CF00N50000002bj33_lkid={!Opportunity.Id}&ctrc15=New&ctrc7={!URLENCODE(Opportunity.Account_Name_TEXT__c) }&ctrc7_lkid={!Opportunity.AccountId}","_top");
}
https://lightning-configuration.salesforce.com/