I have configured the email template for a rule notification to be sent following completion of an action. The email template includes property values of the object edited via the action. The property values to appear in the template are integer values, with display attributes set to numeric formatting > base type=currency (GBP), style=Standard, use grouping=true.
The numeric display formatting is not applied to the values included in the generated email. Is there a way to enforce the display formatting?
template content drops in the raw value, the property’s display formatting doesn’t get applied there. the docs route for anything the template can’t do is switching the content to “From a Function” and formatting it yourself. TSv2 version:
import { Notification } from "@osdk/functions";
import { MyObject } from "@ontology/sdk";
import type { Osdk } from "@osdk/api";
const gbp = new Intl.NumberFormat("en-GB", { style: "currency", currency: "GBP", useGrouping: true });
export default function formattedNotification(obj: Osdk.Instance<MyObject>, newAmount: number): Notification {
const body = `Amount updated to ${gbp.format(newAmount)} (was ${gbp.format(obj.amount ?? 0)})`;
return {
platformNotification: { heading: "Amount updated", content: body, links: [] },
emailNotification: { subject: "Amount updated", body: body, links: [] }
};
}
publish it, then in the action’s notification side effect pick content > From a Function and map the action parameters into it
one gotcha from the docs: ontology data in the notification reflects the object before the action’s edits are applied. so if you pass in the object and read the property, you get the old value. pass the new value parameter from the action straight into the function (newAmount above) for the edited number
also “From a Function” caps recipients at 50 vs 500 for template, in case that matters for you