You need to sign in to do that
Don't have an account?

Changing Javascript to Lightning
Hello,
I am trying to convert a javascript button to a lightning controller. I have the basis of the controller, but how do I add the 'if this oppty type, then select this document' and the 'require these parts' sections in the lightning controller?
Javascript:
//********* Option Declarations (Do not modify )*********//
var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='1';var CEM='';var CES='';var STB='';var SSB='';var SES='';var SEM='';var SRS='';var SCS ='';var RES='';
//********* Page Callout (Do not modify) *********//
if("{!Opportunity.Authorized_Signer__c}" == false)
{
alert('Must select an Authorized Signer to send to');
}
else{
//KIA 4-6-18 Must have Authorized Signer Email Address
if("{!Opportunity.Authorized_Email__c}" == false)
{
alert('Oops! You are trying to send to a contact with no email address. Go to the Contact Record, add an email address and then resend the DocuSign.');
}
else{
//KSJ 3-1-17 Must have agreement terms//
if("{!Opportunity.Agreement_Term__c}" == ''|| "{!Opportunity.Agreement_Term__c}" == null )
{
alert('Agreement Term cannot be blank');
}
else{
//KSJ 3-1-17 Must have auto renewal terms//
if("{!Opportunity.Auto_Renewal_Term__c}" == ''|| "{! Opportunity.Auto_Renewal_Term__c}" == null)
{
alert('Auto Renewal Term must be filled in');
}
else{
//KSJ 3-1-17 Container type cannot be blank//
if("{! Opportunity.Oppty_Type__c }" == "UCO Service" && {!(ISBLANK( Opportunity.Outdoor_Container_Type__c ))})
{
alert('Must have an Outdoor Container Type' );
}
else{
//KSJ 3-1-17 For Trap must have #of trap agreement//
if("{! Opportunity.Oppty_Type__c }" == "Trap Service" && {!(ISBLANK( Opportunity.No_traps_agreement__c ))})
{
alert('# Traps - Agreement cannot be blank' );
}
else{
//KSJ 3-1-17 Indoor container cannot be blank//
if("{! Opportunity.Oppty_Type__c }" == "UCO Service & Indoor Equipment" && "{! Opportunity.Indoor_Container_Type__c}" == '' || "{!Opportunity.Indoor_Container_Type__c}" == null )
{
alert('# Indoor Container Type cannot be Blank' );
}
else{
//KSJ 3-1-17 Must have a quote number//
if("{! Opportunity.Oppty_Type__c }" == "UCO Service & Indoor Equipment" && {!(ISBLANK( Opportunity.Quote_No__c ))})
{
alert('Quote No cannot be blank' );
}
else{
//CES='TEST';
CES='Documents for your Review and Signature';
DST='{!Opportunity.Template_DST__c}';
//DST='XXXXXXXX';
//alert(DST);
//4-17-17 RAM commented out Alert CRL
// Custom Recipient List (Individual)
CRL='Email~{!Opportunity.Authorized_Email__c};LastName~{!Opportunity.Authorized_Signer__c};Role~Authorized Signer;RoutingOrder~1,Email~{!Opportunity.OwnerEmail};FirstName~{!Opportunity.OwnerFirstName};LastName~{!Opportunity.OwnerLastName};Role~Opportunity Owner;RoutingOrder~2,Email~{!Opportunity.Office_Mgr_Email__c};LastName~{!URLENCODE(JSENCODE(Opportunity.Facility__c))};Role~Carbon Copy;RoutingOrder~3';
//alert(CRL);
// Custom Contact Role Map (default config role)
CCRM = 'Authorized Signer~Authorized Signer;Opportunity Owner~Opportunity Owner;Carbon Copy~Carbon Copy';
// Custom Contact Type Map (default Signer)
CCTM = 'Authorized Signer~Signer;Opportunity Owner~Signer;Carbon Copy~Carbon Copy';
OCO='Send';
//********* Page Callout (Do not modify) *********//
window.location.href =
"/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES= "+RES;
}
}
}
}
}
}
}
}
Controller:
I am trying to convert a javascript button to a lightning controller. I have the basis of the controller, but how do I add the 'if this oppty type, then select this document' and the 'require these parts' sections in the lightning controller?
Javascript:
//********* Option Declarations (Do not modify )*********//
var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='1';var CEM='';var CES='';var STB='';var SSB='';var SES='';var SEM='';var SRS='';var SCS ='';var RES='';
//********* Page Callout (Do not modify) *********//
if("{!Opportunity.Authorized_Signer__c}" == false)
{
alert('Must select an Authorized Signer to send to');
}
else{
//KIA 4-6-18 Must have Authorized Signer Email Address
if("{!Opportunity.Authorized_Email__c}" == false)
{
alert('Oops! You are trying to send to a contact with no email address. Go to the Contact Record, add an email address and then resend the DocuSign.');
}
else{
//KSJ 3-1-17 Must have agreement terms//
if("{!Opportunity.Agreement_Term__c}" == ''|| "{!Opportunity.Agreement_Term__c}" == null )
{
alert('Agreement Term cannot be blank');
}
else{
//KSJ 3-1-17 Must have auto renewal terms//
if("{!Opportunity.Auto_Renewal_Term__c}" == ''|| "{! Opportunity.Auto_Renewal_Term__c}" == null)
{
alert('Auto Renewal Term must be filled in');
}
else{
//KSJ 3-1-17 Container type cannot be blank//
if("{! Opportunity.Oppty_Type__c }" == "UCO Service" && {!(ISBLANK( Opportunity.Outdoor_Container_Type__c ))})
{
alert('Must have an Outdoor Container Type' );
}
else{
//KSJ 3-1-17 For Trap must have #of trap agreement//
if("{! Opportunity.Oppty_Type__c }" == "Trap Service" && {!(ISBLANK( Opportunity.No_traps_agreement__c ))})
{
alert('# Traps - Agreement cannot be blank' );
}
else{
//KSJ 3-1-17 Indoor container cannot be blank//
if("{! Opportunity.Oppty_Type__c }" == "UCO Service & Indoor Equipment" && "{! Opportunity.Indoor_Container_Type__c}" == '' || "{!Opportunity.Indoor_Container_Type__c}" == null )
{
alert('# Indoor Container Type cannot be Blank' );
}
else{
//KSJ 3-1-17 Must have a quote number//
if("{! Opportunity.Oppty_Type__c }" == "UCO Service & Indoor Equipment" && {!(ISBLANK( Opportunity.Quote_No__c ))})
{
alert('Quote No cannot be blank' );
}
else{
//CES='TEST';
CES='Documents for your Review and Signature';
DST='{!Opportunity.Template_DST__c}';
//DST='XXXXXXXX';
//alert(DST);
//4-17-17 RAM commented out Alert CRL
// Custom Recipient List (Individual)
CRL='Email~{!Opportunity.Authorized_Email__c};LastName~{!Opportunity.Authorized_Signer__c};Role~Authorized Signer;RoutingOrder~1,Email~{!Opportunity.OwnerEmail};FirstName~{!Opportunity.OwnerFirstName};LastName~{!Opportunity.OwnerLastName};Role~Opportunity Owner;RoutingOrder~2,Email~{!Opportunity.Office_Mgr_Email__c};LastName~{!URLENCODE(JSENCODE(Opportunity.Facility__c))};Role~Carbon Copy;RoutingOrder~3';
//alert(CRL);
// Custom Contact Role Map (default config role)
CCRM = 'Authorized Signer~Authorized Signer;Opportunity Owner~Opportunity Owner;Carbon Copy~Carbon Copy';
// Custom Contact Type Map (default Signer)
CCTM = 'Authorized Signer~Signer;Opportunity Owner~Signer;Carbon Copy~Carbon Copy';
OCO='Send';
//********* Page Callout (Do not modify) *********//
window.location.href =
"/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES= "+RES;
}
}
}
}
}
}
}
}
Controller:
global class DocusignRedirect { private static final STRING PARAM_DSEID = 'DSEID'; private static final STRING PARAM_SOURCE_ID = 'SourceID'; private static final STRING PARAM_SOURCE_CRL = 'CRL'; private Opportunity anOpportunity = null; public DocusignRedirect(ApexPages.StandardController stdController) { Id opportunityId = stdController.getRecord().Id; this.anOpportunity = DAL_Opportunity.getById(opportunityId); } public PageReference autoRun() { if (this.anOpportunity == null) { return null; } PageReference pageRef = Page.dsfs__Docusign_CreateEnvelope; pageRef.getParameters().put(PARAM_DSEID, '0'); pageRef.getParameters().put(PARAM_SOURCE_ID, this.anOpportunity.Id); pageRef.getParameters().put(PARAM_CRL, this.getCRL()); pageRef.setRedirect(true); return pageRef; } private String getCRL() { return 'Email~' + anOpportunity.Authorized_Email__c + ';Name~' + anOpportunity.Authorized_Signer__c + ';RoutingOrder~1;'; } }
Hi Kathryn,
You need to declare this variable:
private static final STRING PARAM_DST='DST';
Use this variable in your page ref parameters to pass:
pageRef.getParameters().put(PARAM_DST,'paste the docusign template ID');
Hope this helps!