DocuSign for Salesforce自定义按钮-自动填充收件人 [英] DocuSign for Salesforce Custom Button - Auto Populate Recipients

查看:86
本文介绍了DocuSign for Salesforce自定义按钮-自动填充收件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Salesforce中有一个自定义按钮,我试图将其配置为自动填充收件人。我有一个与设置了自定义按钮的对象相关的自定义Salesforce对象批准者。批准者对象是Contacts对象的查找关系对象。批准者对象的字段为批准者电子邮件,名字,姓氏和角色。批准者电子邮件,名和姓字段是公式字段,可从联系人那里获取此信息。 角色字段是一个选择列表字段,其中包含与在DocuSign for Salesforce的信封设置中配置的值相同的值。

I have a custom button in Salesforce that I am trying to configure to auto populate the recipients. I have a custom Salesforce object 'Approver' that is related to the object I have the custom button configured for. The approver object is a lookup relationship object to the Contacts object. Approver object has the fields of 'Approver Email', 'First Name', 'Last Name', and 'Role'. Approver Email, First Name, and Last Name fields are formula fields bringing this information from the contact . The Role field is a picklist field that contains the same values as I have configured in my envelope settings for DocuSign for Salesforce.

我试图在按钮中编写代码使用JavaScript自动填充批准者对象中选择的联系人,但是该按钮甚至没有将收件人角色插入信封。以下是我对CCRM,CCTM,CCNM和CRCL部分的JavaScript进行编码的方式。

I have tried to write the code in the button JavaScript to auto populate the contacts selected in the Approver object, but the button is not even inserting recipient roles into the envelope. Below is how I have coded the JavaScript of the sections of CCRM, CCTM, CCNM, and CRCL

任何帮助将不胜感激

CCRM ='1〜Appr 1级别1; 2〜Appr 2级别1; 3〜Appr 3级别1; 4〜Appr 4级别1; 5〜Appr 5级别1; 6〜Reviewer 1; 7 〜Reviewer 2; 8〜Reviewer 3; 9〜Reviewer 4; 10〜Reviewer 5; 11〜Appr 1 Level 2; 12〜Appr 2 Level 2; 13〜Appr 3 Level 2; 14〜Appr 4 Level 2; 15〜Appr 1等级3; 16〜Appr 2等级3; 17〜Appr 3等级3; 18〜Appr 1等级4; 19〜Appr 2等级4; 20〜Appr 1等级5; 21〜Appr 2等级5';
//自定义联系人类型映射
CCTM ='1〜Signer; 2〜Signer; 3〜Signer; 4〜Signer; 5〜Signer; 6〜Acknowledge Receipt; 7〜Acknowledge Receipt; 8〜Acknowledge收据; 9〜确认收据; 10〜确认收据; 11〜签名者; 12〜签名者; 13〜签名者; 14〜签名者; 15〜签名者; 16〜签名者; 17〜签名者; 18〜签名者; 19〜签名者; 20〜签名者; 21〜Signer';
//自定义联系人注释图(默认为无注释)
CCNM =’; //例如:决策者〜DM注释;经济买家〜EB注意; DEFAULT_NOTE〜默认注释'
//自定义相关联系人列表(默认对象联系人)
CRCL ='批准者__r,电子邮件〜 Approver_Email__c; FirstName〜First_Name__c; LastName〜Last_Name__c; ApRole〜Role__c; LoadDefaultContacts〜0'
// Ex:'Approver__r,Email〜Email__c; FirstName〜First_Name__c; LastName〜Last_Name__c; Role〜Role__c,Load / p>

CCRM ='1~Appr 1 Level 1;2~Appr 2 Level 1;3~Appr 3 Level 1;4~Appr 4 Level 1;5~Appr 5 Level 1;6~Reviewer 1;7~Reviewer 2;8~Reviewer 3;9~Reviewer 4;10~Reviewer 5;11~Appr 1 Level 2;12~Appr 2 Level 2;13~Appr 3 Level 2;14~Appr 4 Level 2;15~Appr 1 Level 3;16~Appr 2 Level 3;17~Appr 3 Level 3;18~Appr 1 Level 4;19~Appr 2 Level 4;20~Appr 1 Level 5;21~Appr 2 Level 5'; // Custom Contact Type Map CCTM ='1~Signer;2~Signer;3~Signer;4~Signer;5~Signer;6~Acknowledge Receipt;7~Acknowledge Receipt;8~Acknowledge Receipt;9~Acknowledge Receipt;10~Acknowledge Receipt;11~Signer;12~Signer;13~Signer;14~Signer;15~Signer;16~Signer;17~Signer;18~Signer;19~Signer;20~Signer;21~Signer'; // Custom Contact Note Map (default no note) CCNM = ''; //Ex: 'Decision Maker~Note for DM;Economic Buyer~Note For EB;DEFAULT_NOTE~Default Note' // Custom Related Contact List (default object contact) CRCL ='Approver__r,Email~Approver_Email__c;FirstName~First_Name__c;LastName~Last_Name__c;ApRole~Role__c;LoadDefaultContacts~0' //Ex:'Approver__r,Email~Email__c;FirstName~First_Name__c;LastName~Last_Name__c;Role~Role__c,LoadDefaultContacts~0'

推荐答案


  1. 我认为您分解了按钮代码,请记住这是jscript
    ,而您需要使其可调试

  2. 此处是文档的参考用于Salesforce的Docusign自定义按钮文档
    和此处 DocuSign自定义按钮示例文档对于Salesforce

  3. 我怀疑您要按照文档在CRCL中使用loadDefaultContacts〜1 LoadDefaultContacts参数确定源对象类型的
    默认联系人是否为已加载(0 –不加载
    ,1 –加载)。

  1. I sugest you break down your button code, remember this is jscript and you need to make it debuggable
  2. Here is a reference for the documentation Docusign Custom Button Documentation for Salesforce and here DocuSign Custom Button Sample Documentation for Salesforce
  3. I suspect you want loadDefaultContacts~1 in CRCL per the documentation "The LoadDefaultContacts parameter determines if default contacts for the source object type are loaded (0 – do not load, 1 – load)."

我将如何调试:

a。添加警报(由debug var控制,更改为true以查看警报)

a. Add Alerts (controlled by debug var, change to true to see them)

b。最后添加尝试捕获

b. Add Try Catch finally

c。查看下面的示例自定义按钮,然后与您要完成的操作进行比较,一次只需要一步即可

c. Review the below Sample Custom button and compare to what you are trying to accomplish, taking it one step at a time

d。使用Chrome调试并进入在Salesforce页面上创建的虚拟函数,以便您可以查看从{!} SF令牌等生成的变量和相关值。

d. use Chrome to debug and step into the virtual function that is created on your Salesforce page so you can see the variables and related values that are generated from the {!} SF tokens, etc

-示例常规自定义按钮:-

/*REQUIREMENTS:
   1. Set Email Subject to Opp Name
   2. Set CRL to User
   3. Set signer tyoe to Carbon Copy
   Created for Salesforce Version 5.2
   Source Version of this button 1.0
   Code Reviewed by: Group Accenture

*/

var location ='\\';
var debug = false;


try
{

    var CES = 'Please sign this document for {!URLENCODE(JSENCODE(Opportunity.Name))}';
    var CRL = 'Email~{!URLENCODE(JSENCODE(User.Email))};LastName~{!URLENCODE(JSENCODE(User.Name))};Role~CCSigner;RoutingOrder~1;'; 
    var CCTM = 'CCSigner~Carbon Copy';
    var CCRM = 'CCSigner~CCSigner';

    location = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.id}&CES="+CES+"&CRL="+CRL+"&CCTM="+CCTM+"&CCRM="+CCRM;


}
catch (e)
{

    alert("Error Occured"+e.message);

}
finally
{
    if(debug)
    {
        alert(location);
    }
    else
    {
        window.location.href = location;
    }
}

-使用SOQL和SAPLE复杂自定义按钮建立CRL / CCRM / CCTM-

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

/*REQUIREMENTS:
   1. Set CRL based on Business logic using Product Type and User Roles
   2. Set DST based on Business logci using Product Type
   3. Business Logic (Expand Below here)
      ====See Section Business Rules====
   4. By default this is for sandbox, prod value must be true for it to be using values for Templates in Production mode
   5. This is not a one button click send
   Created for Salesforce Version 5.4
   Source Version of this button 0.5 (beta)
   Code Reviewed by: DocuSign (TBD)

    ====See Section Business Rules====
    DocuSign Button Logic

    1. IF Docusign_Checkbox__c = TRUE 
       AND Sector__c = ‘Life Sciences’
       THEN 
       Signer 1 = Business Integrity Director Role
       Signer 2 = Life Sciences Sector Lead Role

    2. IF Docusign_Checkbox__c = TRUE
       AND Sector__c = ‘Financial Services’
       THEN 
       Signer 1 = Business Integrity Director Role
       Signer 2 = Financial Services Sector Lead Role

    3. IF Docusign_Checkbox__c = TRUE
       AND Sector__c <> ‘Life Sciences’,‘Financial Services’
       THEN 
       Signer 1 = Business Integrity Director Role
       Signer 2 = Health Plans & Providers Sector Lead Role

    4. IF Docusign_Checkbox__c = FALSE
       THEN 
       Signer 1 = Business Integrity Director Role
       Signer 2 = Practice Lead with Signing Power

   Current Questions, Assumptions and clarifications outstanding
a. What client Sign's? 
         i. I see the internal signers, but who is going to sign from the "clients" perspective, or will the person using the button decide
    b. Can you send me the LS template, renamed to txt (xml or zip will not come through)
    c. I will need the production template ids (guids) as they are different from Prod to Demo
    e. What do you want the button to say aka "Send with DocuSign" or something else for your business process
    f. I assume if I am missing the below you want an error message with all the issue shown without allowing the user to send:
        i. No user for Role
        ii. Data for Lead if not DocuSign
    g. I assume the following as well:
        i. The new doc with the 4 scenarios superceds the original email with the different condition
        ii. You don't want to change the default on the below:
            I. Email Subject or Message will be the standard default for the Managed Package in the admin
            II. The expirations and reminders will be the standard default for the Managed Package in the Admin
            III. I will not load the default contacts or attachments
            IV. I will load the recipients based on the business rules only given in the new document
            V. I will load the template based on the business rules only given in the new document
            VI. This is NOT a one button click send

        DEMO
        EBM = DST = 1989696D-F058-42E5-9C5B-8718482E2C1A
        NVS = DST = A906436D-5352-40DE-A9F8-1EE0795E4266
        LS = DST = 4CFE35EC-C8A4-4090-9B72-024F1DE26757

4CFE35EC-C8A4-4090-9B72-024F1DE26757
        PROD
        LS DST
        6048B3CD-D2C5-44BE-9630-51CFCFBD092D

        EBM DST
        B3D6159B-5BE3-4B80-8e8e-96173120D0EF

        NVS DST
        855790D3-6121-496F-B870-D0B276A54611

*/

var location ='\\';
var debug = false;
var prod = false;

//Define Business Rule Functions below for:
// Getting User Role
function getUserInfoForRole(roleName,templateRole, routingOrder)
{
    var recipient = '';

    try
    {

        var result = sforce.connection.query("select id, Email, FirstName, Lastname from User where userroleid in (Select id from UserRole where Name ='"+roleName+"')");
        var userForRole = result.getArray("records");

        recipient = 'Email~'+userForRole[0].Email+';FirstName~'+userForRole[0].FirstName+';LastName~'+userForRole[0].LastName+';Role~'+templateRole+';RoutingOrder~'+routingOrder+';,';

    }
    catch(e)
    {
            if(debug)
            {
                alert(e.message);
            }
    }
    finally
    {

    }

    return recipient;
}

try
{

    //Set DST based on Business Logic 
    var DST = '';

        //Set CRL based on Business Logic in Function (TBD)
    var CRL = ''; 

    //Set Signer Type to Signer for each Role as Signer (Looks to be just two in templates)
    var CCTM = '';

    //Set Signer Type to Signer for each Role (Looks to be just two in templates)
    var CCRM = '';


    if({!Contract.Docusign_Checkbox__c}==1)
    {

        if(debug)
        {
            alert('DocuSign Checked')
        }

        if('{!Contract.Sector__c}' == 'Life Sciences')
        {
            //Signer 1 = Business Integrity Director Role
            CRL = getUserInfoForRole('Business Integrity Director', 'Business Integrity', '1');
            CCTM = 'Business Integrity~Signer;';
            CCRM = 'Business Integrity~Business Integrity;';

            //Signer 2 = Life Sciences Sector Lead Role
            CRL = CRL + getUserInfoForRole('Life Sciences Sector Lead', 'Client Signer', '2');
            CCTM = CCTM + 'Client Signer~Signer;';
            CCRM = CCRM + 'Client Signer~Client Signer;';

            if(debug)
            {
                alert('Life Sciences')
            }

            if(prod)
            {
                DST = '6048B3CD-D2C5-44BE-9630-51CFCFBD092D'
            }
            else
            {
                DST = '686DBA37-EBF3-410F-90E3-7E3F36A95694';
            }

            if(debug)
            {
                alert(DST)
            }

        }
        else if('{!Contract.Sector__c}' == 'Financial Services') 
        {
            //Signer 1 = Business Integrity Director Role
            CRL = getUserInfoForRole('Business Integrity Director', 'Business Integrity', '1');
            CCTM = 'Business Integrity~Signer;';
            CCRM = 'Business Integrity~Business Integrity;';

            //Signer 2 = Financial Services Sector Lead Role
            CRL = CRL + getUserInfoForRole('Financial Services Sector Lead', 'Sector Lead', '2');
            CCTM = CCTM + 'Sector Lead~Signer;';
            CCRM = CCRM + 'Sector Lead~Sector Lead;';


            if(debug)
            {
                alert('Financial Services')
            }

            if(prod)
            {
                DST = 'B3D6159B-5BE3-4B80-8e8e-96173120D0EF'
            }
            else
            {
                DST = '1989696D-F058-42E5-9C5B-8718482E2C1A'
            }

            if(debug)
            {
                alert(DST)
            }           

        }
        else if(('{!Contract.Sector__c}' != 'Life Sciences') && ('{!Contract.Sector__c}' !='Financial Services'))
        {
            if(debug)
            {
                alert('Not Life Sciences or Financial Services')
            }
            //Signer 1 = Business Integrity Director Role
            CRL = getUserInfoForRole('Business Integrity Director', 'Business Integrity', '1');
            CCTM = 'Business Integrity~Signer;';
            CCRM = 'Business Integrity~Business Integrity;';

            //Signer 2 = Health Plans & Providers Sector Lead Role
            CRL = CRL + getUserInfoForRole('Health Plans & Providers Sector Lead', 'Sector Lead', '2');
            CCTM = CCTM + 'Sector Lead~Signer;';
            CCRM = CCRM + 'Sector Lead~Sector Lead;';

            if(prod)
            {
                DST = '855790D3-6121-496F-B870-D0B276A54611'
            }
            else
            {
                DST = 'A906436D-5352-40DE-A9F8-1EE0795E4266'
            }

            if(debug)
            {
                alert(DST)
            }
        }
        else
        {
            //Error
            if(debug)
            {
                alert('Error in Services detection via Sector__c')
            }
        }

    }
    else
    {
        //Signer 1 = Business Integrity Director Role
        CRL = getUserInfoForRole('Business Integrity Director', 'Business Integrity', '1');
        CCTM = 'Business Integrity~Signer;';
        CCRM = 'Business Integrity~Business Integrity;';

        //Signer 2 = Practice Lead with Signing Power
        CRL = CRL + getUserInfoForRole('{!Contract.Sector__c} Lead', 'Practice Lead', '2');
        CCTM = CCTM + 'Practice Lead~Signer;';
        CCRM = CCRM + 'Practice Lead~Practice Lead;';


        if(debug)
        {
            alert('DocuSign NOT Checked')
        }

        if(prod)
        {
            DST = '855790D3-6121-496F-B870-D0B276A54611'
        }
        else
        {
            DST = 'A906436D-5352-40DE-A9F8-1EE0795E4266'
        }

        if(debug)
        {
            alert(DST)
        }       

    }




    //Need Error Check, No OppId, 

    location = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Contract.id}&DST="+DST+"&CRL="+CRL+"&CCTM="+CCTM+"&CCRM="+CCRM;


}
catch (e)
{

    alert("Error Occured"+e.message);

}
finally
{
    if(debug)
    {
        alert(location);
    }
    else
    {
        window.location.href = location;
    }
}

这篇关于DocuSign for Salesforce自定义按钮-自动填充收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆