Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

AssignmentManager

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

completeAssignment(baseUrl, activityId, redirect)

Description

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  

Code Block
languagejs
 AssignmentManager.completeAssignment('http://localhost/jw', '1_1_activity', 'http://localhost/completed.jsp');

completeAssignmentWithVariable(baseUrl, activityId, variableData, redirect)

Description

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  

Code Block
languagejs
AssignmentManager.completeAssignmentWithVariable('http://localhost/jw', '1_1_activity', 'var_status=new&var_id=123', 'http://localhost/completed.jsp');

getCurrentUsername(baseUrl, callback)

Description

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  

Code Block
languagejs
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)

Description

Gets the current logged in username 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  

Code Block
languagejs
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)

Description

Gets the current logged in username 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.  (refer to Hashed Password)
    • callback - a callback function after a successful call (optional)

Sample code  

Code Block
languagejs
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)

Description

Gets the current logged in username in Joget Workflow

Parameters

Sample code  

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

withdrawAssignment(baseUrl, activityId)

Description

Withdraws an assignment with a specific activity instance id

Note

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  

Code Block
languagejs
AssignmentManager.withdrawAssignment('http://localhost/jw', '1_1_activity');

ConnectionManager

  • URL : /jw/js/json/util.js
  • Auto included in all userview pages.
  • Convenient method to do AJAX call.

ajaxJsonp(url, callback, params)

Description

Initiates Ajax call with JSONP

Parameters

    • url - URL to initiate Ajax call
    • callback - a callback function after a successful call (optional)
    • params - parameters for the call (optional)

Sample code 

Code Block
languagejs
var callback = {
    success : function(response){
        //do something
    }
};
ConnectionManager.ajaxJsonp('http://localhost/test', callback, 'id=4&name=test');

get(url, callback, params, xss)

Description

Initiates Ajax GET to a specific URL

Parameters

    • url - URL for GET action
    • callback - a callback function after a successful call (optional)
    • params - parameters for the call (optional)
    • xss - use when the URL is cross-domain (optional)

Sample code 

Code Block
languagejs
var callback = {
    success : function(response){
        //do something
    }
};
ConnectionManager.get('http://localhost/test', callback, 'id=6&name=test', false);

post(url, callback, params)

Description

Initiates Ajax POST to a specific URL

Parameters

    • url - URL for GET action
    • callback - a callback function after a successful call (optional)
    • params - parameters for the call (optional)

Sample code 

Code Block
languagejs
var callback = {
    success : function(response){
        //do something
    }
};
ConnectionManager.post('http://localhost/test', callback, 'id=6&name=test');

FormUtil

  • URL : /jw/js/json/formUtil.js
  • Auto included in page using form.
  • Convenient method to interact with form field.

getField(fieldId)

Description

Used to gets the field object of a form field

Parameters

    • fieldId - id of a form field

Sample code 

Code Block
var field = FormUtil.getField("field1");
$(field).val("test"); //set value

getFieldsAsUrlQueryString(fields)

Description

Used to generates the fields value as url query parameter string

Parameters

    • fields - an array contains objects with "field", "param" and "defaultValue" attributes.
      - field : id of a form field
      - param : paremeter name to be used
      - defaultValue : value to be used when the field return empty value (Optional)

Sample code 

Code Block
languagejs
var fields = [
    {"field":"field1", "param":"p_field1"},
    {"field":"field2", "param":"p_field2"},
    {"field":"field3", "param":"p_field3", "defaultValue":"default value"},
];
 
var queryString = FormUtil.getFieldsAsUrlQueryString(fields);
console.log(queryString); //p_field1=Field1%20value&p_field2=Field2%20value;Field2%20second%20value&p_field3=default%20value

getGridCells(cellFieldId)

Description

Used to gets the cell objects of every rows of a grid field

Parameters

    • cellFieldId - Grid Field Id and the cell id separated by a dot ".". Eg. gridId.cellId

Sample code 

Code Block
languagejs
var cells = FormUtil.getGridCell("gridId.field1");
$(cells).each(function(){
    //do something
});

getGridCellValues(cellFieldId)

Description

Used to gets the cell values of every rows of a grid field and return it in an array.

Parameters

    • cellFieldId - Grid Field Id and the cell id separated by a dot ".". Eg. gridId.cellId

Sample code 

Code Block
languagejs
var values = FormUtil.getGridCellValues("gridId.field1");
for (var i = 0; i < values.length; i++) {
    console.log(values[i]); //i equals to row number start from 0
}

getValue(fieldId)

Description

Used to gets the value of a form field. 

Parameters

    • fieldId - id of a form field

Sample code 

Code Block
languagejs
var value = FormUtil.getField("field1");

getValues(fieldId)

Description

Used to gets the values of a form field. Values will return in array. 

Parameters

    • fieldId - id of a form field

Sample code 

Code Block
languagejs
var values = FormUtil.getValues("field1");
for (var i = 0; i < values.length; i++) {
    console.log(values[i]); 
}

JPopup

  • URL : /jw/js/json/ui_ext.js
  • Auto included in all userview pages.
  • Convenient method to create/show/hide a popup dialog to display a page.

create(id, title, width, height)

Description

Used to creates a popup dialog element.

Parameters

    • id - an unique identifier of the popup dialog
    • title - a title to display for on the top of popup dialog (Optional)
    • width - width of the popup dialog box (Optional)
    • height - height of the popup dialog box (Optional) 

Sample code 

Code Block
languagejs
JPopup.create("testPopup", "Test Popup Dialog");

hide(id)

Used to hides a created and shown popup dialog element.

Parameters

    • id - an unique identifier of the popup dialog

Sample code 

Code Block
languagejs
JPopup.hide("testPopup");

show(id, url, params, title, width, height, action)

Description

Used to creates a popup dialog element.

 Parameters

    • id - an unique identifier of the popup dialog
    • url - an URL of a page to show in popup dialog
    • params - a JSON object to pass parameter and its value (Optional) 
    • title - a title to display for on the top of popup dialog (Optional)
    • width - width of the popup dialog box (Optional)
    • height - height of the popup dialog box (Optional) 
    • action - Get/Post. Default to Post (Optional) 

Sample code 

Code Block
languagejs
var params = {
    id : "1",
    name : "test"
};
 
JPopup.show(frameId, url, params);

 

UI

  • URL : /jw/js/json/ui.js
  • Auto included in all userview pages.
  • Convenient method to retrieve value for UI usages.

adjustPopUpDialog(dialogbox)

...

userviewThemeParams()

UrlUtil

  • URL : /jw/js/json/util.js
  • Auto included in all userview pages.
  • Convenient method to deal with URL.

constructUrlQueryString(params)

...