当前位置:网站首页>Dynamics CRM: 查询字符串参数(Query String Parameters)的使用方法
Dynamics CRM: 查询字符串参数(Query String Parameters)的使用方法
2022-07-21 15:48:00 【Stone-hdj】
查询字符串参数(Query String Parameters)通常被用来传递自定义参数给表单上下文, 我使用它是用来判断用户是从哪里点击的这条记录, 但其实它的用处很多, 需要大家自己来发掘.下面我就来说下它的用法:
1. 创建Query String Parameters
a. Settings -> Customizations -> Customize the System
b. Entities -> <实体名> -> Forms -> <表单名>
c. 进入Form Properties -> 选择Parameters
你可以传递下面几种类型的值:
Boolean
DateTime
Double
EntityType
Integer
Long
PositiveInteger(包括0)
SafeString
UniqueId
UnsignedInt
2. 传递参数值给表单
链接示例:
这个链接的作用是打开指定的Account实体记录, 我们重点说一下最后的这一块&extraqs=parameter_0%3D0
extraqs这个参数是用来传递查询字符串的, 后面接等号, 等号后面到下一个&之前的这部分(如果有)为查询字符串的参数和值, 那我上面例子中的parameter_0%3D0就是URL encode的参数和值, 里面的%3D就是等号(=), 相当于parameter_0=0.
多个参数之间用&分隔, 也就是%26, 例如未编码前为:parameter_0=0¶meter_1=1, 那么编码后就是parameter_0%3D0%26parameter_1%3D1
接着来说一下使用extraqs来传递参数的一些注意事项:
- 必须对在 extraqs 参数中传递的参数进行编码(encodeURIComponent), 就像上面那样
- 查询字符串参数的名称必须匹配或包含实体的属性名称
- 传递的值必须有效, 不能你参数类型是一个布尔,结果你给了一个abc这样的字符串值.
- 该值不能是脚本
- 任何传递无效参数或值的尝试都将导致错误
- 对于布尔字段,可以使用0或1的整数值,或者使用 true 或 false 的文本值来设置该值
- 对于 DateTime 字段,使用日期的文本值
Note:其实还可以这种传递参数的方式来设置字段值, 具体可以参考这个链接:
3. 读取查询字符串
第一种方法:
1. 首先我们需要在页面进行一些设置, 进入Form中的Form Properties, 选择或者创建一个事件
进入这个事件后, 选中'Pass executiuon context as first parameter', 这样就可以把上下文信息通过参数传给这个Test函数
然后我们就可以在代码中使用了
Test: function (executionContext) {
var objFormContext = executionContext.getFormContext();
var para0 = objFormContext.data.attributes.get("parameter_0").getValue();
}
第二种方法(建议不用):
Test: function () {
var params = Xrm.Utility.getGlobalContext().getQueryStringParameters();
var para0 = params["parameter_0"];
}
Note:
1. 第二种方法不需要像第一种方法那样传递上下文给Test函数, 而且在我测试的过程中,我发现我连第一步创建Query String Parameters都不需要,只要在第二步中将参数添加到链接中,然后当有人点击这些链接后来触发事件函数,比如Onload,就可以直接使用Xrm.Utility.getGlobalContext().getQueryStringParameters();来获取所有的参数了
2. 重点来了,就是这种方法在新版的Dynamics CRM已经被废弃了, 所以尽量使用第一种方法来读取查询字符串参数的值, 虽然麻烦点...
Important changes (deprecations) coming in Power Apps and Power Automate - Power Platform | Microsoft DocsImportant changes (deprecations) coming in Power Apps and Power Automatehttps://docs.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated3. 我在测试的时候使用的是Dynamics CRM OP v9.0, 第二种方法还是可以正常使用的, 如果你使用的是9.1,或者online版本,估计第二种方法就不行了.
参考链接:
Configure a form to accept custom querystring parameters (Developer Guide for Dynamics 365 Customer Engagement) | Microsoft Docshttps://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/configure-form-accept-custom-querystring-parameters?view=op-9-1Manage form properties in Dynamics 365 Customer Engagement (on-premises) | Microsoft Docs
https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/customize/form-properties-legacy?view=op-9-1Open forms, views, dialogs, and reports with a URL (Developer Guide for Dynamics 365 Customer Engagement (on-premises)) | Microsoft Docs
https://docs.microsoft.com/zh-cn/dynamics365/customerengagement/on-premises/developer/open-forms-views-dialogs-reports-url?view=op-9-1
边栏推荐
- Dynamics 365: 如何解除实体只能创建2个Access Team Templates的限制
- numpy数组访问的效率研究
- 253会议室 II
- Dynamics CRM: 邮箱配置(三) - 配置Email Server Profiles和Mailboxes
- Encryption crash, Web3 is dead?
- Nonparametric test
- mysql8中timestamp时间戳设置默认值 CURRENT_TIMESTAMP ,Error:1048 - Column ‘createTime‘ cannot be null
- 《通信软件开发与应用》课程结业报告
- 105从前序与中序遍历序列构造二叉树
- 公网官网建站笔记(五):域名工信部备案完整流程并解析公网访问
猜你喜欢
Dynamics 365: how to remove the restriction that an entity can only create two access team templates
Keras深度学习实战(10)——迁移学习
Spirng之注解使用
Common questions of testers during interview
如何生成xmind的复杂流程图
Keras deep learning practice (15) -- realize Yolo target detection from scratch
TMECH发表优必选运控技术最新进展:实现人形机器人高鲁棒性行走
嵌入式开发:使用RTOS的7个技巧
Dynamics 365: 如何在Azure AD中创建用户并添加到Dynamics 365 Online中
集合之HashSet
随机推荐
NoSQL数据库之Redis【数据操作、持久化、Jedis、缓存处理】详解
Web3,加密VC新风口
105从前序与中序遍历序列构造二叉树
[caused by: com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: SQL statement parameters are different from methods]
Fragmentary knowledge - AB experiment
ECCV 2022 | fix the performance damage of large targets caused by FPN: you should look at all objects
Dynamics 365: 查找哪些记录使用Access Team这种方式分享给了某一个User
软件推荐-装机
"New energy + energy storage" starts from the digital twin, Tupu will make smart power to the extreme
感觉的定义
Dynamics 365: usage of access team templates
Pycharm reads jy-901s data
MySQL 将字符串转换为数字类型并进行排序
Azure Key Vault(2):创建Azure Key Vault
带你认识8个软件设计中的谬误
自定义view之----自定义button
IP address classification and range
Dynamics CRM: 为用户和团队共享记录
软件-必备软件
CodeSys中编程实现串口通讯【基于树莓派4B】