You need to sign in to do that
Don't have an account?
LoneStar69
onlcick javascript button in lightning
Guys, i have a onclick javascript button that validates fields, uses different templates based on field values.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
var ca = new sforce.SObject("Case");
var p = "{!Case.Cons__c}";
var email = "{!Case.Cons_Email__c}";
var email2 = "{!Case.Cons_2_Email__c}";
var email3 = "{!Case.Cons_3_Email__c}";
var flc = "{!Case.Topic__c}";
if((email =="")&&(email2 =="")&&(email3 ==""))
{
alert("Please select cons and make sure cons has email address ");
}
else if(flc == ""){
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00X60000004dTuo&p26=cons@gmail.com');
}
else if(flc == "PC-AF") {
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00Xt0000000LxEP&p26=cons@gmail.com');
}
else if(flc != "PC-AF") {
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00Xt0000000LxEt&p26=cons@gmail.com');
}
How to make this button work on lightning, can someone please share the code, thank you.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
var ca = new sforce.SObject("Case");
var p = "{!Case.Cons__c}";
var email = "{!Case.Cons_Email__c}";
var email2 = "{!Case.Cons_2_Email__c}";
var email3 = "{!Case.Cons_3_Email__c}";
var flc = "{!Case.Topic__c}";
if((email =="")&&(email2 =="")&&(email3 ==""))
{
alert("Please select cons and make sure cons has email address ");
}
else if(flc == ""){
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00X60000004dTuo&p26=cons@gmail.com');
}
else if(flc == "PC-AF") {
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00Xt0000000LxEP&p26=cons@gmail.com');
}
else if(flc != "PC-AF") {
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00Xt0000000LxEt&p26=cons@gmail.com');
}
How to make this button work on lightning, can someone please share the code, thank you.
You can implement this button with Quick Actions in Case object. Refer this links.
https://trailhead.salesforce.com/modules/lex_javascript_button_migration/units/javascript_button_alternatives
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/lightning_component_actions.htm
Here is the code i have written so far -
Component - Controller - Apex - The issues that i am having right now -
1) In the logs i see my case id is 'undefined'
2) The field Con_Email__c has an email address, but the flag value is returning 'false' instead of 'true'
3) If i fire the URL on false flag value , it gives me the below error.
Can you help me on this, thank you.
codigo del boton.
switch("{!Opportunity.StageName}"){
case "7. Apartado":
window.open("{!URLFOR("../apex/Aletc_Formato_UnidadCondominal", "")}?id={!Opportunity.Id}");
case "9. Elaboración Contrato":
window.open("{!URLFOR("../apex/Aletc_Formato_UnidadCondominal", "")}?id={!Opportunity.Id}");
break;
default:
alert("No se puede generar contrato para esta Oportunidad con desarrollo {!Opportunity.Desarrollo__c} y etapa {!Opportunity.StageName}, Solo está disponible para la etapa 9. Elaboración Contrato.");
break;
}