1
0
-1

tried to refer to this page for bean shell programming, but its not working, how do i check if the user is from a certain department and not allow them to view certain category in userview

import java.util.Collection;
import java.util.Map;
import org.joget.apps.app.service.AppUtil;
import org.joget.directory.model.Department;
import org.joget.directory.model.User;
import org.joget.directory.model.service.ExtDirectoryManager;
import org.joget.workflow.model.service.WorkflowUserManager;
import org.joget.workflow.util.WorkflowUtil;

public boolean isAuthorized(User user, Map params) {
    //if no logged in user
    if (user == null) {
        return false;
    }
    
    ExtDirectoryManager directoryManager = (ExtDirectoryManager) AppUtil.getApplicationContext().getBean("directoryManager");
    Collection department = directoryManager.getDepartmentByUsername(user.getUsername());
    
    if(department.equals("Legal")){
        return false;
    }else {
        return true;
    }
}

The error im getting is error executing script.


    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      Use https://marketplace.joget.org/jw/web/userview/mp/mpp/_/vad?id=not_permission-v1 then choose the department. Anyone else other than users in this department would be permitted to access.

      1. Di Sheng

        I saw the supported SQL is only MySQL, would it be compatible with MSSQL as well?

      CommentAdd your comment...