1

I have a JavaScript button that's designed to pull in a value from a custom lookup field to a Contact record from an Opportunity record. Does anyone know how I can modify this button to pull that Contact information from the Opportunity Contact Role related list for the cotact who's role is "Signatory"?

{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")} 
//********* Option Declarations (Do not modify )*********// 
var CRL=''; 
var DST=''; 
var CES='';
//*************************************************// 
// Modify individual options here: 
// Related Content (default no related content) 
// Custom Recipient List 
CRL = 'Email~{!JSENCODE(Opportunity.Primary_Contact_Email__c)};
FirstName~{!JSENCODE(Opportunity.Primary_Contact_FirstName__c)};
LastName~{!JSENCODE(Opportunity.Primary_Contact_LastName__c)};
Role~Signer1,Email~test@test.com;FirstName~Test;LastName~Test1;
Role~Signer 2'; 
DST = '0E9AB63C-62C0-4D01-B91A-E58849B7B573'; 
CES='Insertion Order signature request for {!JSENCODE(Opportunity.Account_Name_Rendered__c)}';
//********* Page Callout (Do not modify) *********// 
window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&STB=1&SourceID={!Opportunity.Id}&LA=0&CRL="+CRL+"&DST="+DST+"&CES="+CES; 
//*******************************************//
0

You can use SOQL query in your button. Please see these examples.

Your query will look something like this:

var result = sforce.connection.query("select role " +
" from OpportunityContactRole where contactId = '{!Opportunity.Primary_contact__c}' ");

You'll then parse our result object using examples in the link above.

  • Thanks @dzg. I'm not very familiar with JavaScript. Is it easy to convert this code, which is used for a custom button in the SFDC UI, to a script that I can use for a commandbutton in Visualforce? – J. Neilan Dec 1 '15 at 14:46
  • Not really, they are quite different things. – dzh Dec 1 '15 at 20:27
0

This is possible by leveraging the CCRM (Custom Contact Role Map) variable.

CCRM='Signatory~Signer 3';

You may need to replace "Signer 3" with whatever Template Role you have included.

If you want to include contacts with CRL also, you'll need to include "LoadDefaultContacts" as well within the CRL variable, otherwise it will ignore Contact Roles by default.

Example of all variables would be below:

CRL = 'Email~{!JSENCODE(Opportunity.Primary_Contact_Email__c)};
FirstName~{!JSENCODE(Opportunity.Primary_Contact_FirstName__c)};
LastName~{!JSENCODE(Opportunity.Primary_Contact_LastName__c)};
Role~Signer1,Email~test@test.com;FirstName~Test;LastName~Test1;
Role~Signer 2,LoadDefaultContacts~1'; 

CCRM='Signer1~Signer 1;Signer 2~Signer 2;Signatory~Signer 3';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.