1
0
-1

I have org chart in IT Division, Staff - Sec Head - Dep Head - Div Head.

I want to know how if the staff requests something, the approval goes directly to the division head?

Sorry for my bad english.

    CommentAdd your comment...

    4 answers

    1.  
      2
      1
      0

      Never mind, I've already solve the problem. just use bean shell tool when "map to participant" and insert this code.

      import java.sql.Connection;
      import java.sql.PreparedStatement;
      import java.sql.ResultSet;
      import java.sql.SQLException;
      import javax.sql.DataSource;
      import java.util.ArrayList;
      import java.util.Collection;
      import org.joget.apps.app.service.AppUtil;
      import org.joget.directory.model.User;
      import org.joget.directory.model.service.ExtDirectoryManager;
      import org.joget.workflow.model.WorkflowActivity;
      import org.joget.commons.util.LogUtil;
       
      public Collection getAssignees(WorkflowActivity activity) {
          // retrieve connection from the default datasource
          Connection con = null;
          String deptId = "";
           try {
                DataSource ds = (DataSource)AppUtil.getApplicationContext().getBean("setupDataSource");
                con = ds.getConnection();
               if(!con.isClosed()) {
                  PreparedStatement stmt = con.prepareStatement("SELECT DivisionCode FROM dbo.employee WHERE EmployeeID = ?");
                  stmt.setObject(1, "#currentUser.username#");
                  ResultSet rs = stmt.executeQuery();
                  while (rs.next()) {
                      deptId = rs.getObject("DivisionCode").toString();
                  }
               }
           }catch(Exception e) {
                  LogUtil.error("getAssignees", e, "Error Query");
              } finally {
                  //always close the connection after used
                  try {
                      if(con != null) {
                          con.close();
                      }
                  } catch(SQLException e) {/* ignored */}
              }
         
          Collection assignees = new ArrayList();
           
          ExtDirectoryManager directoryManager = (ExtDirectoryManager) pluginManager.getBean("directoryManager");
           
         ;
           
           
          //Get users using directory manager
          Collection userList = directoryManager.getUsers(null, null, deptId, null, null, null, null, "firstName", false, 0, 1);
          for(Object u : userList){
              User user = (User) u;
              assignees.add(user.getUsername());
          }
           
          return assignees;
      }
       
      //call getAssignees method with injected variable
      return getAssignees(workflowActivity);
      1. aimi

        ohh interesting. So When create user, need to setting who are HOD for each department/division? 

        When requester select department/division, go direct to HOD?

      2. Gustara Putra

        yes, if you have participant from other datasource or table, you can use this code.

      CommentAdd your comment...
    2.  
      1
      0
      -1

       I put user must be select the HOD for approval

        CommentAdd your comment...
      1.  
        1
        0
        -1

        I've already create process, assign "report to" and "assign HOD". After run the process, approval not go to division head, it stuck to performer. Here is my Process and Participant :

         

          CommentAdd your comment...
        1.  
          1
          0
          -1

          Hi, you can design your process with Process Routes, and directly transition to the division head approval activity based on your specific conditions.

            CommentAdd your comment...