SharePoint 2013 SharePoint designer 2013 workflow开发综合实例

本文提供了一个SharePoint 2013 Designer Workflow的综合实例,详细介绍了如何创建一个Site Workflow,调用HTTP Web Service获取新闻列表,并将最新10条新闻以邮件形式发送给站点Visitor组。内容包括环境准备、工作流设计、Json数据处理、邮件发送及注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文讲述一个SharePoint 2013 SharePoint designer 2013 workflow开发综合实例.

在前面这篇博文里面谈到http://blog.csdn.net/abrahamcheng/article/details/8707354 SharePoint 2013 工作流开发的一些概念,笔者将在本篇以及后面几篇博客里面介绍SharePoint 2013 workflow开发综合实例,本篇先说SharePoint designer 2013 workflow开发综合实例。


准备工作:

1. SharePoint 2013 的开发环境

2. 安装SharePoint 2013 designer 

3. 安装配置Workflow manager http://technet.microsoft.com/en-us/library/jj163276.aspx (注意要下面四个软件都装上) 


4.安装 SharePoint server 2013 补丁 kb2817616,不装的话SharePoint 2013的Send mail action发不了邮件,说白了是微软的一个bug,在这个更新里面修了,装完后需要运行配置向导。

5. Outgoing 邮件配置


场景:

某公司内网站点有个新闻列表,需要把最新的10条新闻每天发给站点的Visitor 组。



效果(基本功能效果,没有美化,因为我只是给大家介绍可以这样用):


思路:

使用一个Site workflow来实现,是build dictionary来存储request header (指定返回数据为json格式)


使用Call HTTP Web service 调用

http://moss2013site/_api/web/lists/GetByTitle('News')/items?$select=Title,Body,ID&$top=10&$orderby=Created desc 


这个action会返回一个Json数据

{"d":{"results":[{"__metadata":{"id":"408a322c-b7a4-4651-987d-17789df159d4","uri":"http:\/\/yourSharePoint2013Site\/_api\/Web\/Lists(guid'afb7bd53-c825-42ad-b149-68cf4027330b')\/Items(3)","etag":"\"1\"","type":"SP.Data.NewsListItem"},"Id":3,"Title":"Firstnews from dev home","Body":"First news from dev home body..........","ID":3},{"__metadata":{"id":"a52f1488-de17-4ff0-aa40-ea9d105be65d","uri":"http:\/\/yourSharePoint2013Site\/_api\/Web\/Lists(guid'afb7bd53-c825-42ad-b149-68cf4027330b')\/Items(4)","etag":"\"1\"","type":"SP.Data.NewsListItem"},"Id":4,"Title":"Typhoonand rainstorm in ShangHai on 08\/10\/2013","Body":"Typhoonand rainstorm in ShangHai on 08\/10\/2013 body ....","ID":4}]}}

使用json路径,取得Json中数据记录的条数


初始化mailBody: 


循环Json中数据记录,拼接成邮件内容,分别用Json路径d/result[%Varible:loopIndex%]/Title, d/result[%Varible:loopIndex%]/Body,  d/result[%Varible:loopIndex%]/Id取出Title, Body, Id三个字段的值,并进行拼接:



拼接格式:


拼接完成后发送邮件


因为是要每天发邮件的,因此发完邮件后使用(Pause for Duration)等待一天,再次回到第一个Stage重复每天发送邮件



整个workflow为


注意:

1. 不要使用系统帐号启动该workflow,否则可能出现措误

Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.ApplicationException: HTTP 401 The HTTP response content could not be read. 'Error while copying content to a stream.'


2. 如果Json路径不对,会出现如下错误

The DynamicValue property 'd/results(1) ' was incorrectly formatted. at Microsoft.Activities.Dynamic.DynamicValueBuilder.PathSegmentFactory.Parse


3.如果没有给Call HTTP web service设置request header,会出现如下错误: 

{"error":{"code":"-1, Microsoft.SharePoint.Client.ClientServiceException","message":{"lang":"en-US","value":"The HTTP header ACCEPT is missing or its value is invalid."}}}


4. 如果loopIndex忘记自增,导致死循环,可能出现如下错误

The workflow instance exceeded the throttle of 10000 activities executed in a row and could not be unloaded because it was not persistable

或 内存溢出 memory overflow.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值