English
setData
About 220 wordsLess than 1 minute
2025-09-22
This method is used to update main object data.
Parameters
| Parameter | Description | Type |
|---|---|---|
| changeData | Field data to be changed | Object |
| options | Optional configuration parameters | Object |
Description of the options parameter:
| Parameter | Description | Type | Default |
|---|---|---|---|
| fieldName | Field that triggers the change; required to trigger UI events | String | — |
| triggerUiFieldNames | Fields that trigger UI event changes, used in scenarios where multiple fields are changed at the same time | String Array | — |
| triggerCal | Whether to trigger calculation | Boolean | true |
| triggerUi | Whether to trigger UI events | Boolean | true |
| noCalField | Specify main-object fields that should not trigger calculation | Array | — |
Return Value
Promise, which asynchronously returns the result after calculations and UI events are completed.
Code Example
export default function (context) {
return {
/** After the create/edit page has finished rendering */
renderEnd(){
context.setData({"field_api_name": value}, {
fieldName: 'field_api_name'
}).then(()=>{
console.log("context.setData success.")
});
}
}
}Notes
Avoid calling
context.setDatafrequently. Merge updates as much as possible and call it once.setDatamay trigger asynchronous tasks such as calculations and UI events, and frequent calls may cause concurrency issues.- Frequent calls that trigger UI updates will affect performance and may cause page lag.
let changeData = {k1:1,k2:2} // avoid calling inside loops // incorrect example Object.keys(changeData).forEach(k=>{ context.setData({k: changeData[k]},{fieldName:k}) }) // correct example context.setData(changeData,{fieldName:"k1"})
