Js 查询实体值示例

 var new_accountid=crmForm.all.new_accountid.DataValue[0].id;
var name=GetEntityAttributeByAttribute("account","name","accountid",new_accountid);
var new_shippingmethodid=GetEntityAttributeByAttribute("account","new_shippingmethodid","accountid",new_accountid);
var new_ShipName=GetEntityAttributeByAttribute("new_shippingmethod","new_name","new_shippingmethodid",new_shippingmethodid);
if (new_ShipName=="Sea Transport" && crmForm.all.new_destinationportid.DataValue==null)
  {
     alert("运输方式为Sea transport时目的港不能为空!") ;
     event.returnValue = false;
  }
function GetEntityAttributeByAttribute(EntityName,RetrieveAttributeName,ConditionAttributeName,ConditionAttributeNameValue)
{
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\">" +
GenerateAuthenticationHeader()+
"  <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>" +
"            <q1:Attribute>"+RetrieveAttributeName+"</q1:Attribute>" +
"          </q1:Attributes>" +
"        </q1:ColumnSet>" +
"        <q1:Distinct>false</q1:Distinct>" +
"        <q1:PageInfo>" +
"          <q1:PageNumber>1</q1:PageNumber>" +
"          <q1:Count>50</q1:Count>" +
"        </q1:PageInfo>" +
"        <q1:Criteria>" +
"          <q1:FilterOperator>And</q1:FilterOperator>" +
"          <q1:Conditions>" +
"            <q1:Condition>" +
"              <q1:AttributeName>"+ConditionAttributeName+"</q1:AttributeName>" +
"              <q1:Operator>Equal</q1:Operator>" +
"              <q1:Values>" +
"                <q1:Value xsi:type=\"xsd:string\">"+ConditionAttributeNameValue+"</q1:Value>" +
"              </q1:Values>" +
"            </q1:Condition>" +
"          </q1:Conditions>" +
"        </q1:Criteria>" +
"      </query>" +
"    </RetrieveMultiple>" +
"  </soap:Body>" +
"</soap:Envelope>" +
"";

var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);

var resultXml = xmlHttpRequest.responseXML;
var oXml = new ActiveXObject("Msxml2.DOMDocument");
oXml.loadXML(resultXml.xml);
var roleList= oXml.selectNodes("//BusinessEntity/q1:"+RetrieveAttributeName);
var returnValue="";
    if(roleList.length>0)
    {
         returnValue=roleList[0].text;
    }
  return returnValue;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值