English
setReadOnly
About 232 wordsLess than 1 minute
2025-09-22
Dynamically set a field of an object to read-only or editable.
Parameters
Description of param Properties
| Property | Description | Type | Default | Allowed Values |
|---|---|---|---|---|
| objApiName | Object apiName | String | — | — |
| dataIndex | dataIndex of one or more child object rows | String|Array | — | — |
| fieldName | One or more field apiNames | String|Array | — | — |
| status | Whether to update to read-only state | Boolean | true | true: read-onlyfalse: editable |
| priority | Priority. The larger the number, the higher the priority. Values greater than 10 will override the layout state | Number | 0 | — |
Return Value
None
Code Example
{
event: "form.render.end",
functional: function (pluginExecResult, options) {
console.log("custom plugin: form.render.end exec");
let {dataUpdater}=options;
// Set one field of the main object to read-only
dataUpdater.setReadOnly({
fieldName: 'field_xx__c'
})
// Set multiple fields of the main object to read-only
dataUpdater.setReadOnly({
fieldName: ['field_xx1__c', 'field_xx2__c']
})
// Set some fields of the main object to editable
dataUpdater.setReadOnly({
fieldName: ['field_xx__c'],
status: false
})
// Set certain fields to read-only for all rows of a specified child object
dataUpdater.setReadOnly({
objApiName: 'SalesOrderProductObj',
dataIndex: 'all',
fieldName: ['field_xx__c'],
})
// Set certain fields to read-only for specified rows of a specified child object
dataUpdater.setReadOnly({
objApiName: 'SalesOrderProductObj',
dataIndex: ['1', '2'],
fieldName: ['field_xx__c']
})
}
},Notes
- Default rule: layout-required fields cannot be set to read-only, and layout-readonly fields cannot be set to editable. To skip this rule, configure
isSkipLayoutFieldStateCheckastruein theform.render.beforeevent.
