Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
borderColorgreen
borderWidth1
titleBGColor#ddffcc
borderStylesolid
titleDefinition
Bean Shell Formatter allows you to write custom Java code to transform values on the datalist column.
Panel
borderColorpurple
borderWidth1
titleBGColor#ddccff
borderStylesolid
titleNew Feature

This is a new feature in Joget Workflow v6.

 

Figure 1: Bean Shell Formatter Properties

...

NameDescription
Script

Script in Java.

The entire script is defaulted to be applied to every row in such column, hence user does not need to perform looping to apply transformation to every row.To customize this behaviour, user need to handle datalist, column, row variables appropriately.

Injected variables available for consumption are:-

  • datalist - org.joget.apps.datalist.model.DataList
  • column - org.joget.apps.datalist.model.DataListColumn
  • row - Object in the collection list DataListCollection (org.joget.apps.datalist.model.DataListCollection) returned by the datalist binder DataListBinder (org.joget.apps.datalist.model.DataListBinder). Service method org.joget.apps.datalist.serviceDataListService
    To retrieve the property value from Object row, use this service method: DataListService.evaluateColumnValueFromRow(Object row, String propertyName) can be used to retrieve the property value from the row object.
  • value - String

Returns a String.

Code Block
titleSample Code
linenumberstrue
return value + "append this text to every column value";

 

It is also possible to inject hash variables into the values.

Code Block
titleSample Code
linenumberstrue
return value + " #currentUser.firstName#";

 

Example code using DataListService service method:

Code Block
titleSample Code
linenumberstrue
//import the necessary classes
import org.joget.apps.datalist.service.DataListService;
import org.joget.apps.app.service.AppUtil;

DataListService dataListService = (DataListService) AppUtil.getApplicationContext().getBean("dataListService");
 
//since this entire bean shell applies to every row, "row" is automatically iterated here.
//"name" is the column id
return dataListService.evaluateColumnValueFromRow(row, "name");