I try to complete assignment from plugin but doesnt work.

ApplicationContext applicationContext = AppUtil.getApplicationContext();
        WorkflowManager workflowManager = (WorkflowManager) applicationContext.getBean("workflowManager");
ApplicationContext applicationContext = AppUtil.getApplicationContext();

WorkflowManager workflowManager = (WorkflowManager) applicationContext.getBean("workflowManager");

workflowManager.assignmentComplete("197_61_complain_complain_raiseIssue");

any suggestion?

  • No labels

2 Comments

  1. update :

    is working if :

    1. admin as assignee and

    2. activity status is open.running

  2. Hi,

    The complete assignment only can used for complete assignment of the logged in user. To complete assignment for the other user, you can temporary switch the logged in user and switch it back to the original user later on.

    import org.joget.workflow.model.service.WorkflowManager;
    import org.joget.apps.app.service.AppUtil;
    import org.joget.workflow.model.WorkflowAssignment;
    import org.joget.workflow.model.service.WorkflowUserManager;
    
    WorkflowManager wm = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager");
    WorkflowUserManager wum = (WorkflowUserManager) AppUtil.getApplicationContext().getBean("workflowUserManager");
    
    //username of the assignee who should complete the assignment.
    String username = "cat";
    
    //switch user
    String currentUser = wum.getCurrentThreadUser();
    wum.setCurrentThreadUser(username);
    
    
    try {
        //complete assignment
        wm.assignmentComplete("197_61_complain_complain_raiseIssue");
    } finally {
        //switch back the user
        wum.setCurrentThreadUser(currentUser);
    }

    Hope this helps.