English
Groovy Code Examples
About 506 wordsAbout 2 min
2026-01-09
Three return type application scenarios for button functions:
1 Map
Primarily used for pre-validation functions.
When the return type is Map, it's typically used for page interactions. The returned information should generally include:
- error: Whether an error occurred
- errorMessage: Error message to display when failure occurs
- block: Whether to block saving after displaying error message
- ignoreSendingRemind: Defaults to false. When true, suppresses message sending (this parameter only takes effect in relevant team button functions)
["error": true, "errorMessage": "Error message to display when failure occurs", "block": true]2 String
Returns a String type:
- When content is a valid URL, clicking the button will redirect to that URL
- When content is a non-empty string, clicking the button will display a popup message
- When returning empty string or no content, indicates successful execution
3 UIAction
For scenarios requiring redirection to standard pages or custom components, configure button functions to return UIAction type.
3.1 UIAction Redirect to Detail Page Custom Component:
UIAction openDialogAction = OpenDialogAction.build {
userData = [:] //Key-value pair list data passed to custom component
title = "title" //Dialog title
width = 123 //Width and height
maxHeight = 123 //Maximum height
component { //Component's apiName
apiName = "comp_yuio8__c"
}
}
return openDialogActionThe function's context.data and context.details will be passed to the custom component as default parameters objectData and details.
3.2 UIAction Redirect to List Page Custom Component:
UIAction openDialogAction = OpenDialogAction.build {
userData = [:] //Key-value pair list data passed to custom component
title = "title" //Dialog title
width = 123 //Width and height
maxHeight = 123 //Maximum height
type = "FullScreen" //Display mode, currently supports "ShowCenter" (centered dialog) and "FullScreen" modes
component { //Component's apiName
apiName = "comp_yuio8__c"
}
}
return openDialogActionThe function's context.dataList will be passed to the custom component as default parameter objectIds.
3.3 UIAction Redirect to Standard Component:
//1 Redirect to print template
/**
* data: Parameters required for printing
*/
Map data = [
"validatePreAction" : false, //Pre-validation must be false
"templateId" : "5e994bbfa5083d97d6ae7afa", //Specified print template
"dataId" : "5d428ed922381800018d946c", //Data ID
"orientation" : "Landscape", //Landscape or Portrait
"skipCheckButtonConditions": false //Whether to skip object button display condition checks
]
WebAction action = WebAction.builder()
.type('print')
.data(data)
.build()
return action
//2 Redirect to create page
Map data = [
'apiname' : 'AccountObj',
'record_type': 'default__c'
]
WebAction action = WebAction.builder()
.type('form')
.data(data)
.build()
return action
//3 Redirect to create page with default field values
Map recordData = [
'field_62AcX__c' : "6066ec21fe5dbf0024f67e02", //Assign value to lookup field
'field_62AcX__c__r': "My Product 1", //Must use this method to add main attribute of lookup object data
'name' : 'Backfill'
]
Map data = [
'apiname' : 'object_qe3x1__c',
'record_type': 'default__c',
'data' : recordData,
'details' : [:]
]
WebAction action = WebAction.builder()
.type('form')
.data(data)
.build()
return action
//4 Redirect to URL
UIAction uiAction = WebAction.builder()
.type('url')
.url('www.fxieoke.com')
.build()
return uiAction//Prompt message cannot be empty. The type attribute is reserved for future popup style variations and can be empty (defaults to 'default' when empty)
3.4 UIAction Mobile Page Redirection:
AppAction app = AppAction.builder()
.url('https://www.baidu.com')
.build()
return appWhen URL is a mini-program component:
AppAction app = AppAction.builder()
.url('ava://uipaas_custom/fs_common/pages/custom_components/index?components=[{apiName:]') //Component's apiName
.build()
return app