none
SetLeadState RRS feed

  • 问题

  • 如标题所示,我想在点击自定义按钮之后就将lead的状态值statecode变更,但是依旧报错,信息如下:-1 is not a valid state code on lead.

    环境:CRM4.0

    代码:

    //改变线索状态值
    var stateCode="inactive";
    var entityID=crmForm.ObjectId;

    var authenticationHeader = GenerateAuthenticationHeader();
    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>"+
    "<Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
    "<Request xsi:type='SetStateLeadRequest'>"+
    "<EntityId>"+entityID+"</EntityId>"+
    "<LeadState>"+stateCode+"</LeadState>"+
    "<LeadStatus>2</LeadStatus>"+ 
    "</Request>"+
    "</Execute>"+
    "</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/Execute");
    xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xHReq.setRequestHeader("Content-Length", xml.length);
    xHReq.send(xml);
    // Capture the result.
    var resultXml = xHReq.responseXML;

    // Check for errors.
    var errorCount = resultXml.selectNodes('//error').length;
    if (errorCount != 0)
    {
     var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
     alert(msg);
    }
    // Display a confirmation message and open the campaign record.
    else
    {
    alert("success!");
    }

    哪位大虾能给点意见,万分感激

    2012年6月26日 17:20

全部回复

  • var stateCode="inactive";

    改为

    var stateCode="1"

    状态对应的可用不可用是int类型值的,可用0,停用1,错误信息已经提示出来了



    windows live Id :hellohongfu@hotmail.com

    2012年7月14日 10:35