基本思路:使用SharePoint提供的WebService来获取流程发起人的角色(Web Url/_vti_bin/usergroup.asmx?WSDL)。
1 调用usergroup web Service中的方法GetGroupCollectionFromUser,传入参数流程发起人的AD账号字符串,输出XML文件。
2 使用XSLT解析XML文件,得到流程发起人的role集合。
图示:
执行过程详解
使用Send Notification查看输出地XML文件
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<
xml
>
< GetGroupCollectionFromUser xmlns ="http://schemas.microsoft.com/sharepoint/soap/directory/" >
< Groups >
< Group ID ="4" Name ="Absence Requests Owners" Description ="Use this group to give people full control permissions to the SharePoint site: Absence Requests" OwnerID ="4" OwnerIsUser ="False" />
</ Groups >
</ GetGroupCollectionFromUser >
</ xml >
< GetGroupCollectionFromUser xmlns ="http://schemas.microsoft.com/sharepoint/soap/directory/" >
< Groups >
< Group ID ="4" Name ="Absence Requests Owners" Description ="Use this group to give people full control permissions to the SharePoint site: Absence Requests" OwnerID ="4" OwnerIsUser ="False" />
</ Groups >
</ GetGroupCollectionFromUser >
</ xml >
XSLT的详细代码如下所示
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<
xsl:stylesheet
version
="1.0"
xmlns:xsl
="http://www.w3.org/1999/XSL/Transform"
xmlns:h
="http://schemas.microsoft.com/sharepoint/soap/directory/"
>
< xsl:template match ="/" >
< xsl:for-each select ="xml/h:GetGroupCollectionFromUser/h:Groups/h:Group" >
< xsl:value-of select ="@Name" /> ; </ xsl:for-each >
</ xsl:template >
</ xsl:stylesheet >
< xsl:template match ="/" >
< xsl:for-each select ="xml/h:GetGroupCollectionFromUser/h:Groups/h:Group" >
< xsl:value-of select ="@Name" /> ; </ xsl:for-each >
</ xsl:template >
</ xsl:stylesheet >
解析role集合使用“;”隔开每个数组元素并输出的字符串如下所示:
Absence Requests Owners;
如果发起人用户所属多个用户,则如下所示:Absence Requests Owners;HR;Payroll;
流程文件下载:download