English
Groovy Code Example
About 192 wordsLess than 1 minute
2026-01-09
/**
* @type classes
* @returntype
* @namespace object_controller_plugin
*/
class ObjCtrl3jScM implements ObjectControllerPlugin {
/**
* Pre-query logic that returns query conditions
* Commonly used to modify database query conditions
*/
ObjectController.BeforeResult before(FunctionContext context, ObjectController.BeforeArg arg){
log.info(arg)
def code = arg.getCode()
log.info(code)
// if( code[0]=="RelatedList" ){
// }
def triggerInfo = arg.getTriggerInfo()
log.info(triggerInfo)
def triggerPage = triggerInfo.getTriggerPage()
log.info(triggerPage)
def controllerArg = arg.getControllerArg()
def search_query_info = controllerArg["search_query_info"] as String
// search_query_info is a string type, needs to be deserialized to map first
def searchQueryInfo= Fx.json.parse(search_query_info)
// Modify object template
// Serialize the modified searchQueryInfo back to search_query_info
search_query_info = Fx.json.toJson(searchQueryInfo)
log.info(search_query_info)
controllerArg["search_query_info"]=search_query_info
return ObjectController.BeforeResult.builder()
.controllerArg(controllerArg)
.supportAfter(true)
.build();
}
/**
* Post-query event from database
* Can perform secondary processing on data returned to users through functions
* Examples: calculation, encryption/decryption, hiding
*/
ObjectController.AfterResult after(FunctionContext context, ObjectController.AfterArg arg){
def controllerResult = arg.getControllerResult()
List<Map> dataList = controllerResult["dataList"] as List
log.info(dataList)
def triggerInfo = arg.getTriggerInfo()
log.info(triggerInfo)
def triggerPage = triggerInfo.getTriggerPage()
log.info(triggerPage)
if( "Button" == triggerPage ){
dataList.each{
it["owner"] = null
}
}
log.info(dataList)
return ObjectController.AfterResult.builder()
.controllerResult(controllerResult)
.build();
}
// Debug entry method
void debug(FunctionContext context, Map arg) {
}
}