How to set if a certain department cant view this category in userview with bean shell programming

Confluence User - 14 Sep, 2023

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.


userviews;beanshell;user

2


17 Sep, 2023
confluenceUser
1
confluenceUser

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.

21 Sep, 2023
confluenceUser
confluenceUser

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

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print