CRM2011通过ribbon按钮启动工作流
2013-06-28 10:35
519 查看
在实施的项目中,有时候客户可能会觉得点击系统的工作流按钮显得有些繁琐,因为在点击运行完之后,系统还会弹出一个对话窗口,让你确认是否继续:沟通之后,发现他们想要的不是这种有意识的点击“Next”,而是友好的提醒你:“流程开始运行了”之类的话。现在我们可以通过在表单窗体的Ribbon上添加一个按钮,然后将Ribbon的Action链接到一个JS文件,并指定函数名,在JS文件中实现启动工作流的操作。一.为了简化操作,用Visual Ribbon Editor for CRM2011来实现添加按钮,下面为”客户“窗体添加一个”StartWorkflow“按钮:切换到Action选项卡,如图:编辑完成之后,点击”Save“按钮,即可导入CRM中,在CRM2011的客户窗体中,显示如下:前面配置的时候命名是”StartWorkflow“,由于工具默认使用的语言是1033,但系统使用的是2052,所以在这里被显示成”自定义“。二.新建一条工作流,并记下工作流guid,工作流设置成"作为按需流程",最后激活流程三.创建new_workflow.js文件,并发布点击“文本编辑器”,录入如下内容:
ExecuteWorkflow = function(entityId, workflowId){ // Soap Request for Executing Workflow var executeWorkflowSoapRequest = "" + "<?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>" + " <Execute xmlns=\'http://schemas.microsoft.com/crm/2007/WebServices\'>" + " <Request xsi:type=\"ExecuteWorkflowRequest\">" + " <EntityId>" + entityId + "</EntityId>" + " <WorkflowId>" + workflowId + "</WorkflowId>" + " </Request>" + " </Execute>" + " </soap:Body>" + "</soap:Envelope>" + ""; // using ajax for the request var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); xmlHttpRequest.setRequestHeader("SOAPAction",'http://schemas.microsoft.com/crm/2007/WebServices/Execute'); xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlHttpRequest.setRequestHeader("Content-Length", executeWorkflowSoapRequest.length); xmlHttpRequest.send(executeWorkflowSoapRequest); // response of the workflow request var resultXml = xmlHttpRequest.responseXML; } function OnClickRibbon() { // Get the guid of the workflow created. This can be retrieved from the url of the workflow // page. var workflowProcessID = '423f415e-6612-492b-a186-306a4ace3b4d'; // Get entity Name var entityName = Xrm.Page.data.entity.getEntityName(); // Get Type Code for entity var entityID = Xrm.Page.data.entity.getId(); // stores the response whether workflow has executed or any error. var executeWorkflowResponse = ''; executeWorkflowResponse = ExecuteWorkflow(entityID, workflowProcessID); alert("流程开始运行了,亲!"); }
上面蓝色字体部分替换成前面记录的流程GUID即可。四.刷新某一“客户”记录窗体,并点击之前创建的Ribbon按钮,显示如下:
相关文章推荐
- crm2011中通过JS脚本方式显示和隐藏ribbon中的自定义按钮
- MSCRM2011 通过JS脚本操作ribbon按钮(显示隐藏、是否可用等)
- Dynamics CRM2011中通过JS脚本方式显示和隐藏ribbon中的自定义按钮
- Dynamics CRM2011中通过JS脚本方式显示和隐藏ribbon中的自定义按钮
- Dynamics CRM2011中通过JS脚本方式显示和隐藏ribbon中的自定义按钮
- Dynamics CRM2011中通过JS脚本方式显示和隐藏ribbon中的自定义按钮
- Dynamics CRM 2011 编程系列(33):Ribbon的开发三(按钮的执行环境)
- 通过启动禁止按钮改变后台数据库数据
- 一起谈.NET技术,通过XOML或者XAML的方式创建和启动工作流
- Dynamics CRM 2011 编程系列(32):Ribbon的开发二(按钮的禁用规则)
- Android中使用Notification并通过点击Notification启动启动通知详细Activity,点击返回键和按钮返回主界面
- crm2011通过服务得到当前用户id
- MS CRM 2011 RC中的新特性(9)—全新的工作流 脚本设计模式
- MS CRM2011 通过sql插入数据
- 通过点击一个按钮启动一个TimePicker时刻表
- activiti 工作流会签 / 多人审批时一人通过也可 / 在当前节点获取下一节点的信息 / 流程部署之后发布之前获取所有节点的信息 / 流程启动开始之前传送之后节点办理人 / 同一结点设置多个监听
- Dynamics CRM 2011 通过工作流发邮件时的权限问题
- 通过按钮 启动NSTimer定时器 控制视图view移动效果
- VS2010中获取并调用CRM2011中的工作流
- 通过按钮跳过SplashActivity(启动画面),延时自动跳过SplashActivity进入MainActivity