How do I display the currency of a amount field in a column of an overview table? (version 2020.02)
Alternatively: How can I add an expression as a column?
(Is there a ticket for it?)
How do I display the currency of a amount field in a column of an overview table? (version 2020.02)
Alternatively: How can I add an expression as a column?
(Is there a ticket for it?)
I dont know how it is in version 2020.02. But in the version we use you only need to implement a āConversionServiceā. You can give it as property to the overview engine and then you can controll which formatter is used by A12 Model Annotations:
import { ConversionService } from "@com.mgmtp.a12/validation-api/lib/main/conversion/api";
export class OverviewConverters implements ConversionService {
private readonly simpleConverters = new SimpleConverters();
private readonly currencyFormatScale2;
constructor(locale) {
this.currencyFormatScale2 = new Intl.NumberFormat(locale, { style: "currency", currency: "EUR" });
}
convertToDocument(value: string, field: Field, locale: Locale): BaseType {
if (value === null || value === undefined || value === "-") {
return undefined;
}
const annotation = field.annotations.format;
const format = annotation && annotation.value.value;
switch (format) {
case "number_scale_2": return this.numberFormatScale2.format(Number(value));
default: return this.simpleConverters.convertToUI(value, field, locale);
}
}
}
Regarding your second question:
Currently, expressions are not supported by the overview engine. Though, there is ongoing discussion if and how the feature should be implemented.
For further information and updates on this topic, see [A12-10465]<INTERNAL_LINK>