function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Marcel HobizalMarcel Hobizal 

Javascript List View Button Help

First, I'm not a programmer, but know enough to be dangerous!  This is a Custom List View button on the Contact Record using the DocuSign script.  I'd like to loop around the DocuSign java.

My error is I do not understand how to push the correct SourceID into the DocuSign script from the array that is stored.  I need to send one contact ID (SourceID={!Contact.Id}) to the Page Callout routine below.  

How do I do that or is that even possible?

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 

var records = {!GETRECORDIDS($ObjectType.Contact)};
var strIDs=''; 
if (records[0] == null) 

alert('Please select a record'); 

else 

for (var n=0; n<records.length; n++) 

if(strIDs == '') 
strIDs = records[n]; 
else 
strIDs = strIDs + "," + records[n] ; 



{!REQUIRESCRIPT("/apex/dsfs__DocuSign_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=''; var CEM=''; var CES=''; var STB='';
var SSB=''; var SES=''; var SEM=''; var SRS=''; var SCS ='';
var RES=''; 
//*************************************************// 
CRL = 'Email~{!Contact.Email};LastName~{!JSENCODE(Contact.LastName)};Role~A;RoutingOrder~1';
CCRM = 'A~Signer 1';
CCTM = 'A~Signer';
CRCL = '';
OCO = 'Send'; 
DST = 'ABD09037-D838-4FB7-AB14-6C685547DD4B'; 
LA = '0'; 
CEM = ''; 
CES = ''; 
RES = ''; 
CES = '{!JSENCODE(Contact.Name)} - HR Documentation Packet 2015';
CEM = '{!Contact.FirstName},\\n\\nPlease review, complete and sign the attached HR Documentation Packet 2015.\\n\\nKind Regards,\\n{!User.FirstName}\\n\\n{!User.FirstName} {!User.LastName}\\n{!User.Title}\\n\\nMain {!User.Main_Phone__c}\\nDirect {!User.Phone}\\nFax {!User.Fax}';
//********* Page Callout (Do not modify) *********// 
window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Contact.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;
//*******************************************/

}
}
William TranWilliam Tran
While it looks to be possible, before we proceed, please answer the following:

What happen today when the button is clicked? Does a page appear? or is it all background processing?

Thx
HobieHobie
William, the script currently takes you to a DocuSign screen and says the SouceID is not correct and to contact the system admin.
William TranWilliam Tran
Hobie, 

If a screen is open, how will it be usable if user select 10 contact, 10 screens will open? or only the last screen is open? 

Usability aside.

There are a few optons (this is not beginner's code, it's more compicated)

1) you need to create/wrap the docusign code in a function and call that function in your loop.
2) you could just take the whole docusign code and put it inside you loop change the contact parameter to you records[n] contact.
3) you could create a visualfoce page and move the iteration/docusign code in there.

Last you should test that

var records = {!GETRECORDIDS($ObjectType.Contact)};

records are the actual contact objects not just the ids.

Let me now if this make sense.  You quickest best is to try to use technique 2.

thx.
Marcel HobizalMarcel Hobizal
I did what you recommended via #2 above, and that can work.  The problem still exists is that you have to send the email address and few other fields from Salesforce to DocuSign.  The GetRecordsID function in Salesforce only does what it implies.  Just stores the record ids.

Is there a function that will grab the other fields and store them in an array?