Dynamic CRM 2016使用WEB API 模拟用户查询记录(js)
2017-10-14 13:57
399 查看
本篇主要介绍了在Dynamic CRM WEB API中如何进行用户模拟查询数据
执行模拟的过程相当简单。在进行数据请求发送到Web服务,
在HTTP Request Header中追加MSCRMCallerID参数值等于模拟用户的systemuserid即GUID值。
对比代码如下:
impersonateRetrieveUsingWebAPIFetchxml 查询结果如下:
执行模拟的过程相当简单。在进行数据请求发送到Web服务,
在HTTP Request Header中追加MSCRMCallerID参数值等于模拟用户的systemuserid即GUID值。
对比代码如下:
//常规查询,权限为最高管理员权限 function RetrieveUsingWebAPIFetchxml() { debugger; var fetchxml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + "<entity name='account'>" + "<attribute name='name' />" + "<attribute name='primarycontactid' />" + "<attribute name='telephone1' />" + "<attribute name='accountid' />" + "</entity>" + "</fetch>"; var req = new XMLHttpRequest(); req.open("GET", encodeURI(Xrm.Page.context.getClientUrl() + "/api/data/v8.0/accounts?fetchXml=" + encodeURI(fetchxml), true)); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.onreadystatechange = function () { if (this.readyState == 4 /* complete */) { req.onreadystatechange = null; if (this.status == 200) { var data = JSON.parse(this.response).value; } else { var error = JSON.parse(this.response).error; } } }; req.send(); impersonateRetrieveUsingWebAPIFetchxml(); } //模拟查询,权限小于最高管理员权限 function impersonateRetrieveUsingWebAPIFetchxml() { debugger; var fetchxml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + "<entity name='account'>" + "<attribute name='name' />" + "<attribute name='primarycontactid' />" + "<attribute name='telephone1' />" + "<attribute name='accountid' />" + "</entity>" + "</fetch>"; var req = new XMLHttpRequest(); var impersonateUserId = "7AEBF217-91AF-E711-80C8-CD6AC961FE61";// UserGUID req.open("GET", encodeURI(Xrm.Page.context.getClientUrl() + "/api/data/v8.0/accounts?fetchXml=" + encodeURI(fetchxml), true)); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("MSCRMCallerID", impersonateUserId); req.onreadystatechange = function () { if (this.readyState == 4) { req.onreadystatechange = null; if (this.status == 200) { if (JSON.parse(this.response).value.length > 0) var dataImpersonate = JSON.parse(this.response).value; } else { var error = JSON.parse(this.response).error; } } }; req.send(); }RetrieveUsingWebAPIFetchxml查询结果如下:
impersonateRetrieveUsingWebAPIFetchxml 查询结果如下:
相关文章推荐
- Dynamic CRM 2016使用WEB API创建查询记录(js)
- Dynamic CRM 2016使用WEB API删除记录(js)
- Dynamic CRM 2016使用WEB API FetchXml查询特定记录(js)
- Dynamic CRM 2016使用WEB API更新记录(js)
- 寻找热门查询:搜索引擎会通过日志文件把用户每次检索使用的所有检索串都记录下来,每个查询串的长度为1-255字节。
- js技术--cookie基础(封装cookie、使用cookie记录上一次用户登录名)
- 寻找热门查询:搜索引擎会通过日志文件把用户每次检索使用的所有检索串都记录下来,每个查询串的长度为1-255字节。
- 使用 Web API 模拟其他用户
- 在非SQL客户端使用命令行方式定期连接SQL Server 服务器并模拟用户查询操作,同时输出信息内容
- SharePoint 2013 使用JQuery 一些记录如(SharePoint js 获得当前用户)等基本操作。
- Access数据库:它已经被别的用户以独占方式打开,操作必须使用一个可更新的查询,不能锁定文件
- 使用ASP记录在线用户的数量的代码
- Mocha BSM端到端响应时间管理——模拟用户使用方式
- ORACLE用户常用数据字典的查询使用方法
- 使用mysql的disctinct group by查询不重复记录
- 解决了使用Firefox登录网通上网记录查询网页的问题
- ORACLE用户常用数据字典的查询使用方法
- 使用distinct在mysql中查询多条不重复记录值的解决办法
- mysql使用rand随机查询记录效率测试
- 使用连接(JOIN)来代替子查询(Sub-Queries) mysql优化系列记录