AssignmentManager

This page details the AssignmentManager endpoints and the actions they support. It covers key functions, parameters, and sample code for easy implementation.

  • URL: /jw/js/json/util.js
  • Auto included in all userview pages.
  • Used to deal with assignment of a logged in user.

Chromium has a more strict CORS policy. Therefore, the Javascript execution from another domain to attempt to set the session cookie to the Joget domain has been blocked.

 

completeAssignment(baseUrl, activityId, redirect)

Completes an assignment with a specific process instance id & activity instance id.

  • Parameters:
    • baseUrl - base URL of Joget Workflow, e.g., 'http://localhost/jw'
    • activityId - activity instance id of the assignment to be completed
    • redirect - a URL to redirect to after the assignment is completed (optional)
  • Sample code:
 AssignmentManager.completeAssignment('http://localhost/jw', '1_1_activity', 'http://localhost/completed.jsp');

 

completeAssignmentWithVariable(baseUrl, activityId, variableData, redirect)

Completes an assignment with a specific process instance id & activity instance id with option to set workflow variables.

  • Parameters: 
    • baseUrl - base URL of Joget Workflow, e.g., 'http://localhost/jw'
    • activityId - activity instance id of the assignment to be completed
    • variableData - variables to be set. All variable name must prefix with "var_"
    • redirect - a URL to redirect to after the assignment is completed (optional)
  • Sample code
AssignmentManager.completeAssignmentWithVariable('http://localhost/jw', '1_1_activity', 'var_status=new&var_id=123', 'http://localhost/completed.jsp');

 

getCurrentUsername(baseUrl, callback)

Gets the current logged in username in Joget Workflow.

  • Parameters: 
    • baseUrl - base URL of Joget Workflow, e.g., 'http://localhost/jw'
    • callback - a callback function after a successful call
  • Sample code:
var callback = {
    success : function(response){
        //response.username
        if(response.username != "roleAnonymous"){
            console.log("Username is " + response.username);
        }else{
            console.log("User is anonymous");
        }
    }
};
AssignmentManager.getCurrentUsername('http://localhost/jw', callback);

 

login(baseUrl, username, password, callback)

Login the user in Joget Workflow.

  • Parameters: 
    • baseUrl - base URL of Joget Workflow, e.g., 'http://localhost/jw'
    • username - username for user to login
    • password - password for user to login
    • callback - a callback function after a successful call (optional)
  • Sample code:  
var callback = {
    success : function(response){
        //response.username && response.isAdmin
        if(response.username != "roleAnonymous"){
            console.log("username (" + response.username + ") is " + ((response.isAdmin !== undefined && response.isAdmin === "true")?"admin":"not an admin"));
        }else{
            console.log("Fail to login user!");
        }
    }
};
AssignmentManager.login('http://localhost/jw', 'admin', 'admin', callback);

 

loginWithHash(baseUrl, username, hash, callback)

Login the user with hash in Joget Workflow.

  • Parameters:
    • baseUrl - base URL of Joget Workflow, e.g., 'http://localhost/jw'
    • username - username for user to login
    • hash - hashed password for user to login.  (See Hashed Password)
    • callback - a callback function after a successful call (optional)
  • Sample code:
var callback = {
    success : function(response){
        //response.username && response.isAdmin
        if(response.username != "roleAnonymous"){
            console.log("username (" + response.username + ") is " + ((response.isAdmin !== undefined && response.isAdmin === "true")?"admin":"not an admin"));
        }else{
            console.log("Fail to login user!");
        }
    }
};
AssignmentManager.loginWithHash('http://localhost/jw', 'admin', '14ACD782DCFEB2BCDE2B271CCD559477', callback);

 

logout(baseUrl)

Logs out the current logged in username in Joget Workflow.

AssignmentManager.logout('http://localhost/jw');

 

withdrawAssignment(baseUrl, activityId)

Withdraws an assignment with a specific activity instance id.

Deprecated since v3, the concept of accept & withdraw assignment is removed. 

  • Parameters:
    • baseUrl - base URL of Joget Workflow, e.g., 'http://localhost/jw'
    • activityId - activity instance id of the assignment to be withdrawn
  • Sample code:
AssignmentManager.withdrawAssignment('http://localhost/jw', '1_1_activity');

 

Created by Damian Last modified by Aadrian on Dec 13, 2024