1

I have created a workflow using kaleo workflow.In this i am trying to assign a task to multiple users,I used groovy script in scripted assignment tag for this.But its not working .when am putting two userid's in user object,first one gets replaced and second user got the approvel task. also i used users arraylist for this,like roles in kaleo single approver scripted assignment definition.but no use.

How can i manage this.

This is my code.

            roles=null;
            Connection con = null;
            Statement stmt = null;
            ResultSet rs = null;
            String secondid;
            try
            {                   

            Class.forName(dbDriver);
            con= (Connection) DriverManager.getConnection(dbUrl,dbUser,dbPwd);

                stmt = con.createStatement();                   
                rs = stmt.executeQuery("select ap1,ap2 from test where id = '"+userId+"'");
                users=new ArrayList<User>();                    
                while (rs.next()) 
                    {                       
                    println "approverid one"+rs.getInt(1);
                    println "approverid two"+rs.getInt(2);
                       user=UserLocalServiceUtil.getUser(Long.parseLong(rs.getString(1)));
user=UserLocalServiceUtil.getUser(Long.parseLong(rs.getString(2)));

                    users.add(user);
                    println "array list:"+users;
                    }
                rs.close(); 
                con.close();                
             }                              
            catch(SQLException e)
            {
                e.printStackTrace();
            }
            catch(ClassNotFoundException e)
            {
                e.printStackTrace();
            }           

            ]]>
    </script>
            <script-language>groovy</script-language>
        </scripted-assignment>

when am adding two user id in user tag.also it indicate error in definition while uploading.

4

1 回答 1

1

简而言之,使用角色。在控制面板中,您可以指定角色并向其添加用户。或者,如果您更愿意以编程方式执行此操作,(尽管我仍会事先创建角色)如下所示:(并且我假设您可以获得或拥有一组 userIds

//Already created array of userIds like
// [10180,10191], etc.
roles=new ArrayList<Role>();
try {
    Role r = RoleLocalServiceUtil.getRole(companyId, roleName);
    if (r.getType()==RoleConstants.TYPE_REGULAR) {
        UserLocalServiceUtil.addRoleUsers(r.getRoleId(), userIds);
    } else {
        UserGroupRoleLocalServiceUtil.addUserGroupRoles(userIds, groupId, r.getRoleId());
    }
    roles.add(r);
} catch (SystemException e) {
    e.printStackTrace();
} catch (PortalException e) {
    e.printStackTrace();
}

只需在您的脚本分配定义中扔掉它或它的一些近似值或调用它。如果需要,请先使用UserLocalServiceUtil.unsetRoleUsers或类似的方法从角色中清除旧用户。

于 2014-07-16T05:04:54.370 回答