none
crm 自定义重复检测功能 分享 RRS feed

  • 问题

  • 表单中Onsave中
    var Attributes=new Array();
    Attributes[0]="zz_accountid";
    var Conditions=new Array();
    Conditions[0]=new Array

    ("zz_accountid","Equal",crmForm.all.zz_accountid.DataValue[0].id.replace

    ("{","").replace("}",""));
    Conditions[1]=new Array

    ("zz_zywqjid","Equal",crmForm.all.zz_zywqjid.DataValue[0].id.replace

    ("{","").replace("}",""));
    Conditions[2]=new Array

    ("zz_productid","Equal",crmForm.all.zz_productid.DataValue[0].id.replace

    ("{","").replace("}",""));
    Conditions[3]=new Array

    ("zz_systemuserid","Equal",crmForm.all.zz_systemuserid.DataValue

    [0].id.replace("{","").replace("}",""));
    var resultXml=MyRetrieveMultiple("zz_zlccx", Attributes, Conditions);
    var results=resultXml.getElementsByTagName('BusinessEntity');
    if(results.length>0)
    {
    alert("已经有相同的临床纯销了,不能再新建了!");
    event.returnValue=false;
    return false;
    }

    //根据条件取记录,支持多条件,多记录和取多字段
    function MyRetrieveMultiple(EntityName, Attributes, Conditions) {
        var authenticationHeader = GenerateAuthenticationHeader();
        //            var authenticationHeader = "";
        var sAttributes;
        var sConditions;
        sAttributes = "";
        sConditions = "";
        for (var i = 0; i < Attributes.length; i++) {

            sAttributes += "<q1:Attribute>" + Attributes[i] + "</q1:Attribute>";
        }
        for (var i = 0; i < Conditions.length; i++) {

            var Con = Conditions[i];
            sConditions += "<q1:Condition>";
            sConditions += "<q1:AttributeName>" + Con[0] +

    "</q1:AttributeName>";
            sConditions += "<q1:Operator>" + Con[1] + "</q1:Operator>";
            sConditions += "<q1:Values>";
            sConditions += "<q1:Value xsi:type='xsd:string'>" + Con[2] +

    "</q1:Value>";
            sConditions += "</q1:Values>";
            sConditions += "</q1:Condition>";
        }
        // Prepare the SOAP message.
        var xml = "<?xml version='1.0' encoding='utf-8'?>" +
                 "<soap:Envelope

    xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" +
                 " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
                 " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
                 authenticationHeader +
                 "<soap:Body>" +
                 "<RetrieveMultiple

    xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
                 "<query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query'"

    +
                 " xsi:type='q1:QueryExpression'>" +
                 "<q1:EntityName>" + EntityName + "</q1:EntityName>" +
                 "<q1:ColumnSet xsi:type='q1:ColumnSet'>" +
                 "<q1:Attributes>" +
                 sAttributes +
                 "</q1:Attributes>" +
                 "</q1:ColumnSet>" +
                "<q1:Distinct>false</q1:Distinct>" +
                "<q1:Criteria>" +
                "<q1:FilterOperator>And</q1:FilterOperator>" +
                "<q1:Conditions>" +
                sConditions +
                "</q1:Conditions>" +
                "</q1:Criteria>" +
                "</query>" +
                "</RetrieveMultiple>" +
                "</soap:Body>" +
                "</soap:Envelope>";
        // Prepare the xmlHttpObject and send the request.
        var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
        xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
        xHReq.setRequestHeader("SOAPAction",

    "http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
        xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
        xHReq.setRequestHeader("Content-Length", xml.length);
        xHReq.send(xml);
        var resultXml = xHReq.responseXML;
        return resultXml;
    }

    2010年4月15日 1:30

全部回复

  • 你的业务逻辑是,检测体系中是否存在,存在则提示,不让保存。

    原来我们这是用plugin实现的。

    后来,我们业务要求,是重复问题保存,并且两个建立关联,互相共享数据,关闭一个。显示的那个要在注中显示。

    最后考虑性能与代码量,是在sql中写的TRIGGER.

     


    http://www.5dteam.net
    2010年4月20日 2:01