Custom DataElement Label
This option overrides the name of the instance.
Therefore, this option should not be combined with a functional name
field.
DataElement
This option is used to add a display name to a DataElement, which is shown to users rather than the default display name. The default display name will show either the value of the name
field if that field was added to the element or a generated name based on the database identifier.
A value must be given for the display name option. This value can be formatted to include the values of one or more fields, which will be separated by colons when displayed. The field names in the option value should be separated by underscores.
<options>
<hasDisplayName>user_role</hasDisplayName>
</options>
Given the following database record for a DataElement:
user | role |
---|---|
Freddy | admin |
The following display names can be expected:
Option value | Display name |
---|---|
user | Freddy |
user_role | Freddy:admin |
Other Formats
This option does not provide any syntax for formatting, other than including one or more other fields in the display name. If a more customized display name is required, it is possible to implement the getCustomDisplayName()
method in the CRUDS class of the DataElement.
private Option<String> getCustomDisplayName(ParameterContext<ExampleData> dataParameter) {
Option<String> result = none();
/* return some(string), to override default displayName */
// anchor:custom-displayName:start
// <== Insert your custom display name code here.
// Assign to result as in the following example:
result = some("Example display name");
// anchor:custom-displayName:end
return result;
}