sharepoint 工作流个人代理第一个审批人做代理 时 添加权限的问题

 

下面是个人代理第一个审批人做代理 添加权限的问题

问题1:在代理委托类里直接添加 当前审批人权限,流程里 删除已所有人权限,会把加过的权限删除。

2、先执行 item.update();再添加权限。重新发起流程,权限加上了,但流程提示走到第一个审人节点出错(工作流无法更新此项目,可能是因为此项目的一个或多个列需要其他类型的信息),表单的单据状态也没有改变,还是草稿状态

 

 

 

2 #region 添加审批权限代码

 

            try

            {

                SPSecurity.RunWithElevatedPrivileges(delegate()

                {

                    using (SPSite site = new SPSite(approver.ParentTask.WFContext.Web.Site.ID))

                    {

                        using (SPWeb currentWeb = site.OpenWeb(approver.ParentTask.WFContext.Web.ID))

                        {

 

                                                 

                            SPListItem superItem = currentWeb.Lists[approver.ParentTask.WFContext.ListID].GetItemById(approver.ParentTask.WFContext.ItemID);

                            currentWeb.AllowUnsafeUpdates = true;

                         

                            SPRoleDefinition roleDefinition = currentWeb.RoleDefinitions.GetByType(SPRoleType.Administrator);

                           

                          

                             SPUser user = currentWeb.EnsureUser(toUsername);

                            if (user != null)

                            {

 

                              

                                if (!superItem.HasUniqueRoleAssignments) {

                                    superItem.BreakRoleInheritance(false);

                                                                   

                                    SPUser Curreusername = currentWeb.EnsureUser(userID); //代理人

                                    SPRoleAssignment currentRoleCurre = new SPRoleAssignment(Curreusername.LoginName, Curreusername.Email, Curreusername.Name, Curreusername.Notes);

                                    currentRoleCurre.RoleDefinitionBindings.Add(roleDefinition);

                                    superItem.RoleAssignments.Add(currentRoleCurre);

                                   

                                    SPUser Author = new SPFieldUserValue(currentWeb, superItem["Author"].ToString()).User;//发起人

                                    if (Author.LoginName.ToLower() != user.LoginName.ToLower())

                                    {

                                      

                                        SPRoleAssignment currentRoleAuthor = new SPRoleAssignment(Author.LoginName, Author.Email, Author.Name, Author.Notes);

                                        currentRoleAuthor.RoleDefinitionBindings.Add(roleDefinition);

                                        superItem.RoleAssignments.Add(currentRoleAuthor);

                                    }

                               

                                }

                              

                              

                                SPRoleAssignment currentRole = new SPRoleAssignment(user.LoginName, user.Email, user.Name, user.Notes);//审批人

                                currentRole.RoleDefinitionBindings.Add(roleDefinition);

                                superItem.RoleAssignments.Add(currentRole);

                              

                                                         }

 

                            superItem.SystemUpdate();

                            comment += "a4";

                       // currentWeb.AllowUnsafeUpdates = false;

                    

                         

                        };

                    }

                });

            }

            catch (Exception ex)

            {

               

                new FlowManException("设置代理审批人单据权限出错", ex);

            }

         

            #endregion

转载于:https://www.cnblogs.com/netboys/articles/2218248.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值