English
format_field_value
About 250 wordsLess than 1 minute
2025-04-28
This method allows you to parse the value of a field type into readable content.
FxUI.objectApi.format_field_value(fieldDescribe:Object, value:any, fullValue: string )Parameters
| Parameter | Description | Type | Optional Values | Default |
|---|---|---|---|---|
| fieldDescribe | Describe information of the field (required) | Object | — | — |
| value | The field value | * | — | — |
| fullValue | All values related to the field | string | — | — |
Code Example
const field = {
api_name: 'field_lookup__c',
type: object_reference,
label: 'Related Customer',
}
const data = {
field_lookup__c: '5f2bb8364e6e300001824a37',
field_lookup__c__r: 'Sample Company'
}
const value = FxUI.objectApi.format_field_value(field, data[field.api_name], data);
console.log(value); // Sample CompanyNotes
1. About the value and fullValue parameters
Assume there is a field with apiName field_lookup__c, and its type is object_reference.
The stored data for this field looks like this:
var fieldData = {
field_lookup__c: '5f2bb8364e6e300001824a37',
field_lookup__c__r: 'Name of the lookup object'
}You can see that storing this field involves two parameters, and some fields may even involve three parameters. For this API, fieldData.field_lookup__c is value, and fieldData is fullValue.
You can refer to the code example above to understand these parameters.
2. Usage tip
In most cases, it is difficult to determine exactly how many stored parameters a field has. A practical approach is to pass all retrieved data as fullValue, for example:
const field = {
api_name: 'field_lookup__c',
type: object_reference,
label: 'Related Customer',
...
}
const data = {
field_lookup__c: '5f2bb8364e6e300001824a37',
field_lookup__c__r: 'Sample Company',
// Values of other fields below
name: 'Sample Name',
_id: '23zd323asdf33333asddx2333s3',
field1__c: '233',
field1__c: '233',
field1__c: '233',
...
}
const value = FxUI.objectApi.format_field_value(field, data[field.api_name], data);
console.log(value); // Sample Company