通过DocuSign自定义按钮发送验证

时间:2014-10-17 13:59:42

标签: salesforce visualforce apex docusignapi

在这里寻找一些开发人员的帮助(对于代码来说还是新手)但是我知道这是可能的,因为我有类似的工作线索。

基本上我想在机会上使用docusign按钮为发送创建一个自定义按钮,首先验证机会以确保满足所有最低标准。为此,我知道我将需要一个显示错误消息的VisualForce页面,一个APEX类和/或自定义按钮本身。验证运行时,我希望它看看:

  1. 机会上的几个自定义字段
  2. 机会有与之相关的产品
  3. 至少确定了一个联系人角色
  4. 每次单击该按钮时,它会检查这些条件并显示任何错误,只有在满足所有条件后,才允许用户前进到docusign设置。

    有人可以帮忙吗?

    APEX类

    public class ReadyforDocuSignValidation 
    {
        public id opportunityobjid {get; set;}
        public String error {get; set;}
        public String reft {get; set;}
        public Boolean sterr {get; set;}
        public String sterrmsg {get; set;}
        public ReadyforDocuSignValidation (ApexPages.StandardController controller)
        {
            sterr=false;
            sterrmsg ='To send via DocuSign you must have added a contact role';
            error = 'Please complete the following fields before conversion:<br/>';
            reft ='';
            opportunityobjid = ((opportunity) controller.getRecord()).id;
            Opportunity opportunityobj = [select TOB_Billing_Entity__c, Split_Date_1__c, Split_1__c, Does_This_Include_Recurring__c from Opportunity where id =: opportunityobjid];
    
            if (opportunityobj.TOB_Billing_Entity__c == null ||
                opportunityobj.Split_Date_1__c == null ||
                opportunityobj.Split_1__c == null ||
                opportunityobj.Does_This_Include_Recurring__c == null)
            {
                reft = '1';
                if(opportunityobj.TOB_Billing_Entity__c == null) {error = error + '- TOB Billing Entity />';}
                if(opportunityobj.Split_Date_1__c == null){error = error + '- Split Dates />';}
                if(opportunityobj.Split_1__c == null){error = error + '- Split % />';}
                if(opportunityobj.Does_This_Include_Recurring__c == null){error = error + '- Recurring Products? />';}
            }
            if (opportunityobj.Stage != 'Ready for Docusign')
            {
                //sterr = true;
                if (reft == '1')
                {
                    sterr = true;
                }
                else
                {
                    error = '';
                    reft = '1';
                    sterr = true;
                }
            }         
        }
    }
    

    Visualforce Page

    <apex:page standardController="Opportunity" showheader="false" extensions ="ReadyforDocuSignValidation">
        <style>
            h2
            { width: 300% !important; }
        </style>
        <script>
            window.onload = function() {
                window.onblur = function(){window.close();
            }
            if(document.getElementById('sd').innerHTML == "")
            {
                var ids = document.getElementById('ids').innerHTML;
                window.opener.location.href="/apex/docusign_editenvelope?DSEID=" + ids + "&rc=&SourceID=" + ids;
                window.top.close ();
            }
            else
            {
                settimeout(function(){
                winndow.close();
            }, 10000);
            }};
        </script>
           <div id="sd" style="display": none;">{!reft}</div>
           <div id="ids" style="display: none;">{!opportunityobjid}</div>
        <apex:pageBlock title="ReadyforDocuSign">
          <apex:pageBlockButtons location="bottom">
              <button onclick="window.close();">Close</button>
         </apex:pageBlockButtons>
          <apex:pageMessage severity="error" strength="1">
              <apex:outputText value="{!error}" escape="false" />
              <apex:outputText value="{!sterrmsg}" escape="false" rendered="{!sterr}"/><br />         
          </apex:pageMessage>
      </apex:pageBlock>                                                                            
    </apex:page>
    

    按钮

    var url = "/apex/ReadyforDocuSignValidation?id={!Opportunity.Id}"; 
    var width = "350"; 
    var height = "350"; 
    window.open(url, '','scrollbars=no,resizable=no,status=no,toolbar=no,menubar=no, width=' + width + ',height=' + height + ',left=' + ((window.innerWidth - width)/2) + ',top=' + ((window.innerHeight - height)/2) );
    

0 个答案:

没有答案