在Dynamics 365中使用SURVEYJS代替对话(Dialog)制作话术
本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复269或者20180318可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong.me 。
微软官方有个文档:Important changes coming in Dynamics 365 Customer Engagement ,文档中明确提到,已经不推荐使用对话(Dialogs are deprecated),当然,它原生不支持多语言,这也是一个缺点(可以动脑经通过获取当前用户语言打开不同的Dialog来模拟支持多语言),原文如下:
Dialogs are deprecated
You can use a Dialog process to create an interactive step-by-step data entry form that requires user input to start and run to completion. When you start the dialog process, a wizard-like interface is presented; users make selections or enter data as they progress through each page of the wizard.
Dialogs are deprecated and are replaced by mobile task flows (available as of the December 2016 update), and business process flows. Both task flows and business process flows will continue to evolve to make the transition easier.
那我们如果要制作像对话一样的东西,可有类似的Js框架可以使用?搜索了一下找到了一个,叫做 SURVEYJS,官方网址是 https://surveyjs.io ,开源的(看起来是使用TypeScript写的),MIT协议,该协议是可以商用的,需要保留版权和许可信息,下面这张图表明了MIT协议的特征:

闲话少说,我们来讲讲如何用,我这里使用JQuery版本吧,首先需要利用Web资源功能新建一个JQuery的Web 资源,这个很多项目有我就不多说了。然后下载SURVEYJS,下载的比较大,3M多,我到 https://jscompress.com/ 网站将其压缩后只有 483k了(注意默认的压缩去掉了版权声明等注释,不符合使用协议,我这里没有时间去继续研究了),勉强可以,创建的Web资源如下:

因为还会用到它的一个css文件,我也上传下,如下图:

然后我用代码做个简单的例子吧,它支持多语言,这对于全球部署很重要,建立如下的Web资源来展示:

代码如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>罗勇测试SURVEYJS</title>
<script type="text/javascript" src="../../common/js/jquery.min.js"></script>
<script type="text/javascript" src="../../common/js/survey.jquery.min.js"></script>
<script src="../../../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<link href="../../common/css/survey.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="surveyElement"></div>
<div id="surveyResult"></div>
<script type="text/javascript">
var mycustomSurveyStrings = {
pagePrevText: "My Page Prev",
pageNextText: "My Page Next",
completeText: "OK - Press to Complete",
};
Survey.surveyLocalization.locales["my"] = mycustomSurveyStrings;
Survey.StylesManager.applyTheme("default");
var json = {
title: "素格格新疆特产店调查问卷",
pages: [
{
title: "购买次数",
questions: [
{
type: "radiogroup", name: "buytime", isRequired: true, colCount: 3, title: "你在素格格新疆特产店购买过几次?",
choices: [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"9"
]
}
]
},
{
title: "出售产品",
questions: [
{
type: "checkbox", name: "products", title: "Plese select from the list",
colCount: 4, isRequired: true, title: "素格格新疆特产店主要出售哪些产品?",
choices: ["巴旦木", "碧根果", "葡萄干", "无花果", "纸皮核桃", "开心果", "葡萄酒", "牛肉干",
"奶酪", "纯牛奶", "香蕉牛奶", "天山乌梅", "蜂蜜", "青川黑木耳", "茶树菇", "香菇"]
}
]
},
{
title: "请告知我们你的姓名和邮箱",
questions: [
{ type: "text", name: "name", title: "姓名:" },
{ type: "text", name: "email", title: "邮箱:" }]
}]
}; window.survey = new Survey.Model(json);
survey.onComplete.add(function (result) {
document.querySelector('#surveyResult').innerHTML = "result: " + JSON.stringify(result.data);
var clientURL = GetGlobalContext().getClientUrl();
var req = new XMLHttpRequest()
req.open("POST", encodeURI(clientURL + "/api/data/v8.0/ly_tests"), 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 == 204) {
var testUri = this.getResponseHeader("OData-EntityId");
Xrm.Utility.alertDialog("创建成功的罗勇测试试题记录的URI: " + testUri)
}
else {
var error = JSON.parse(this.response).error;
Xrm.Utility.alertDialog("创建罗勇测试实体记录出错." + error.message);
}
}
};
var test = {};
test.ly_name = result.data.name;//单行文本
test.ly_optionset = 364750000 + Number(result.data.buytime);//选项集
test.ly_multilinetext = result.data.products.join('/');//多行文本
test.ly_singlelinetext = result.data.email;
req.send(JSON.stringify(test));
});
survey.locale = 'zh-cn';
$("#surveyElement").Survey({
model: survey
})
</script>
</body>
</html>
我这里让用户点击命令栏按钮执行如下代码来打开这个Web资源:
var recordId = Xrm.Page.data.entity.getId();
var recordType = Xrm.Page.data.entity.getEntityName();
var webResourceName = "ly_/test/page/SURVEYJSTest.html";
Xrm.Utility.openWebResource(webResourceName + "?typename=" + recordType + "&id=" + recordId, null, 800, 600);
效果如下图,可以看到默认的主题效果还是不错的:



我这里提交后利用填写的资料向CRM插入了一条记录:

插入记录的详情如下,可以看到插入记录的值是填写的值。

在Dynamics 365中使用SURVEYJS代替对话(Dialog)制作话术的更多相关文章
- 自定义工作流活动报错:您无法登陆系统。原因可能是您的用户记录或您所属的业务部门在Microsoft Dynamics 365中已被禁用。
本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复265或者20170926可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong.me ...
- 将Dynamics 365中的用户及其角色、角色导出到Excel中
关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复240或者20161204可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong. ...
- Dynamics 365中的应用程序介绍
本人微信和易信公众号:微软动态CRM专家罗勇 ,回复275或者20180630可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong.me ...
- Dynamics 365中配置和使用文件夹级别的跟踪(folder-level tracking)
本人微信和易信公众号:微软动态CRM专家罗勇 ,回复274或者20180630可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong.me ...
- Dynamics 365工作流报错:您无法登陆系统。原因可能是您的用户记录或您所属的业务部门在Microsoft Dynamics 365中已被禁用。
本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复265或者20170926可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong.me ...
- Dynamics 365中开发和注册插件介绍
我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...
- Dynamics 365中部分账号使用系统明显缓慢怎么办?先这么干!
摘要: 本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复263或者20170828可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyon ...
- Dynamics 365中自定义工作流活动获取的上下文分析及注意事项
关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复244或者20170306可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong. ...
- Dynamics 365中的非交互式账号(Non-interactive User)介绍
摘要: 本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复272或者20180616可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyon ...
随机推荐
- 我们为什么要搞长沙.NET技术社区(三)
我们为什么要搞长沙.NET技术社区(三) 万事先从饭局开始是中华民族留下来的一个优秀的传统美德. 昨天晚餐时间,长沙 .net 技术社区的主要发起人员进行了一番小聚,同时也作为一个非正式会议,对社区发 ...
- FluentDataflow - Fluent Style TPL Dataflow
我的新英文博客文章: FluentDataflow - Fluent Style TPL Dataflow 介绍了本人最新发布的一个开源类库:FluentDataflow--Fluent风格的TPL ...
- proxy_pass根据path路径转发时的"/"问题记录
在nginx中配置proxy_pass时,如果是按照^~匹配路径时,要注意proxy_pass后的url最后的/.当加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理 ...
- [Swift]LeetCode71. 简化路径 | Simplify Path
Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", ...
- [Swift]LeetCode101. 对称二叉树 | Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For e ...
- [Swift]LeetCode266.回文全排列 $ Palindrome Permutation
Given a string, determine if a permutation of the string could form a palindrome. For example," ...
- [Swift]LeetCode524. 通过删除字母匹配到字典里最长单词 | Longest Word in Dictionary through Deleting
Given a string and a string dictionary, find the longest string in the dictionary that can be formed ...
- [Swift]LeetCode528. 按权重随机选择 | Random Pick with Weight
Given an array w of positive integers, where w[i] describes the weight of index i, write a function ...
- [Swift]LeetCode861. 翻转矩阵后的得分 | Score After Flipping Matrix
We have a two dimensional matrix A where each value is 0 or 1. A move consists of choosing any row o ...
- mysql之delete语法
一:DELETE语法 以往用delect删除表数据是都是单表(一个表)删除.对于关联表,往往都是先删除第一个表的数据,然后再写另一个delect语句删除另一个表的数据(浪费时间,又影响性能,与数据库交 ...