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.
Injected variables available for consumption are:-
- datalist - org.joget.apps.datalist.model.DataList
- column - org.joget.apps.datalist.model.DataListColumn
- row - Object in DataListCollection (org.joget.apps.datalist.model.DataListCollection) returned by DataListBinder (org.joget.apps.datalist.model.DataListBinder).
To retrieve the property value from Object row, use this service method: DataListService.evaluateColumnValueFromRow(Object row, String propertyName)
- value - String
Returns a String.
Code Block |
---|
title | Sample Code |
---|
linenumbers | true |
---|
|
return value + "append this text to every column value"; |
It is also possible to inject hash variables into the values.
Code Block |
---|
title | Sample Code |
---|
linenumbers | true |
---|
|
return value + " #currentUser.firstName#"; |
Example code using DataListService service method:
Code Block |
---|
title | Sample Code |
---|
linenumbers | true |
---|
|
//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");See Bean Shell Programming Guide - Datalist Formatter.