+ Start a Discussion
Chris BroChris Bro 

Multiple Buttons for Multiple DocuSign Contracts - combine to ONE button and determine Contract based on Field or Something else

Hi.  I have multiple custom buttons on a custom object, each of which corresponds to a different contract in DocuSign - and subsequently sends a different contract based on city. This means that there are currently 40 buttons to determine which contract to send from DocuSign. Needless to say, this is ridiculous and takes forever to load.

I would like to have ONE button to submit contracts, and have that button intelligently find which contract to send based on a picklist value or a formula field.

My current code for each button looks like this:
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
{!REQUIRESCRIPT("/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/ajax/20.0/apex.js")}

if({!D__c.P__c==''}) {alert("Please make sure that Status is YES and that the Check is in PASS and that the Date is filled in");
} else {
var RC = '';var RSL='';var RSRO='';var RROS='';var CCNM='';var CRCL=''; var OCO='';var DST='';var LA='';var CEM='';var CES='';varSTB='';var SSB='';var SES='';var SEM='';var SRS='';var SCS ='';var RES='';var CRL = 'Email~{!D__c.Email__c};FirstName~{!D__c.FirstName__c};LastName~{!D__c.LastName__c};Role~A;RoutingOrder~1';var CCRM='A~Signer1';var CCTM='A~Signer';
RC = 'GetRelContentIDs("{!D__c.Id}")';
OCO='Tag';
DST='A1234567890-B0987654321-C13579';
LA='0';
STB='1';
SSB='1';
SES='1';
SEM='1';
CES='Please DocuSign these documents';
CEM='Hi-\\n\\nWe wanted to let you know some stuff... Attached is an Agreement for you to complete...';
window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!D__c.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="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
}


In the code sample above:
DST='A1234567890-B0987654321-C13579';
determines what template to use...

What I would like to do, is have DST='the string value of D__c.Some_Formula_Field__c' so that I can then populate this Some_Formula_Field__c with the necessary reference to the DocuSign contract automatically, so I can just use ONE button.

Can anyone help me?
Best Answer chosen by Chris Bro
Forza di SognoForza di Sogno
You're pretty close, you just weren't referencing the current D__c object.  Try this:
 
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
{!REQUIRESCRIPT("/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/ajax/20.0/apex.js")}

var DObj = new sforce.SObject("D__c");
var sP = "{!D__c.P__c}";
var sDST = "{!D__c.Some_Formula_Field__c}";

if(sP=='') 
{
	alert("Please make sure that Status is YES and that the Check is in PASS and that the Date is filled in");
} 
else 
{
var RC = '';
var RSL='';
var RSRO='';
var RROS='';
var CCNM='';
var CRCL=''; 
var OCO='';
var DST='';
var LA='';
var CEM='';
var CES='';
varSTB='';
var SSB='';
var SES='';
var SEM='';
var SRS='';
var SCS ='';
var RES='';
var CRL = 'Email~{!D__c.Email__c};FirstName~{!D__c.FirstName__c};LastName~{!D__c.LastName__c};Role~A;RoutingOrder~1';
var CCRM='A~Signer1';
var CCTM='A~Signer';
RC = 'GetRelContentIDs("{!D__c.Id}")';
OCO='Tag';

//DST='A1234567890-B0987654321-C13579';
DST = sDST;
LA='0';
STB='1';
SSB='1';
SES='1';
SEM='1';
CES='Please DocuSign these documents';
CEM='Hi-\\n\\nWe wanted to let you know some stuff... Attached is an Agreement for you to complete...';

window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!D__c.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="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
}

 

All Answers

Forza di SognoForza di Sogno
You're pretty close, you just weren't referencing the current D__c object.  Try this:
 
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
{!REQUIRESCRIPT("/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/ajax/20.0/apex.js")}

var DObj = new sforce.SObject("D__c");
var sP = "{!D__c.P__c}";
var sDST = "{!D__c.Some_Formula_Field__c}";

if(sP=='') 
{
	alert("Please make sure that Status is YES and that the Check is in PASS and that the Date is filled in");
} 
else 
{
var RC = '';
var RSL='';
var RSRO='';
var RROS='';
var CCNM='';
var CRCL=''; 
var OCO='';
var DST='';
var LA='';
var CEM='';
var CES='';
varSTB='';
var SSB='';
var SES='';
var SEM='';
var SRS='';
var SCS ='';
var RES='';
var CRL = 'Email~{!D__c.Email__c};FirstName~{!D__c.FirstName__c};LastName~{!D__c.LastName__c};Role~A;RoutingOrder~1';
var CCRM='A~Signer1';
var CCTM='A~Signer';
RC = 'GetRelContentIDs("{!D__c.Id}")';
OCO='Tag';

//DST='A1234567890-B0987654321-C13579';
DST = sDST;
LA='0';
STB='1';
SSB='1';
SES='1';
SEM='1';
CES='Please DocuSign these documents';
CEM='Hi-\\n\\nWe wanted to let you know some stuff... Attached is an Agreement for you to complete...';

window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!D__c.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="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
}

 
This was selected as the best answer
Chris BroChris Bro
This worked, except I removed line 5:

var DObj = new sforce.SObject("D__c");