diff --git a/docs/8.0/ayanova/docs/form-ay-report-edit.md b/docs/8.0/ayanova/docs/form-ay-report-edit.md index 8f583fe0..57ab56fd 100644 --- a/docs/8.0/ayanova/docs/form-ay-report-edit.md +++ b/docs/8.0/ayanova/docs/form-ay-report-edit.md @@ -43,7 +43,7 @@ function reportPreRender(reportData) { } ``` -Note that the SAMPLE DATA section of the user interface in the report designer shows the raw data as it is passed to this function, *not* how it would look after this function is run. +Note that the SAMPLE DATA section of the user interface in the report designer shows the raw data *before* it is passed to this function, not how it would look *after* this function is run. A common use for this section would be to insert or change data based on calculations or data fetched from external API's or the AyaNova API itself (see the section regarding API usage below for details). @@ -52,12 +52,12 @@ A common use for this section would be to insert or change data based on calcula This section is for custom [Handlebars helper functions](https://handlebarsjs.com/guide/#custom-helpers) defined by the user. AyaNova comes with many pre-defined helpers documented below, but this section is where you can add your own. Any helper compatible with Handlebars can be defined here. You can even use AyaNova API methods in your helpers if required (see the section regarding API usage below for details). ### Sample Data + This is displayed in the report designer user interface when the report designer is opened via a business object. The sample data is temporary and displayed for the purpose of assisting during report design as a reference to the field names available to the report. If you do not see this section it means the report designer was opened directly without passing through a business object first so there is no current data to display but you can still edit the report as normal. This can happen if you open a report from a History form or use the browser back button to go back to a report that was previously edited or open a report URL directly. - ## Render process When a report is rendered the following steps take place behind the scenes: @@ -76,15 +76,33 @@ Several helpers are pre-defined for use with reports: Format value as all capitals: -```{ ayCaps ReportFieldName }}``` +```{{ ayCaps ReportFieldName }}``` -### ayMarkdown +### ayCurrency -Format a Markdown formatted field such as a Wiki field on an object into HTML in a similar manner to how they are displayed in the AyaNova user interface WIKI fields: +Formats a raw currency decimal value into a currency value formatted for the locale of the Client or server / report default -```{ ayMarkdown wiki }}``` +```{{ ayCurrency cost }}``` +### ayDate + +Formats a raw DateTime stamp into a short date only (no time) in the locale format of the Client or server / report default + +```{{ ayDate startDate }}``` + +### ayDateTime + +Formats a raw DateTime stamp into a short date and short time in the locale format of the Client or server / report default + +```{{ ayDateTime startDate }}``` + + +### ayDecimal + +Formats a raw decimal number value into a floating point value formatted for the locale of the Client or server / report default + +```{{ ayDecimal quantity }}``` ### ayJSON @@ -99,11 +117,11 @@ Will output the Client meta data sent along with the report request from the Cli Format an URL properly in the displayed document: -```{ ayLink text_displayed url_link }}``` +```{{ ayLink text_displayed url_link }}``` e.g. -```{ ayLink 'AyaNova website' 'https://www.ayanova.com' }}``` +```{{ ayLink 'AyaNova website' 'https://www.ayanova.com' }}``` Will display as text and url: [AyaNova website](https://www.ayanova.com) @@ -119,14 +137,84 @@ For example: Will render the small sized logo as an image tag set to the correct API Url. Note that if you do not upload a logo then this will display a broken image icon instead. +### ayMarkdown + +Format a Markdown formatted field such as a Wiki field on an object into HTML in a similar manner to how they are displayed in the AyaNova user interface WIKI fields: + +```{{ ayMarkdown wiki }}``` + +This is what you use to display a Wiki (or any Markdown formatted text) in a report. AyaNova uses the [Marked](https://marked.js.org/) library to turn Markdown into HTML for display both in the user interface and in reports. + +### ayT + +Translates an AyaNova translation key into the language indicated by the current logged in user or the server default: + +```{{ ayT 'Customer' }}``` + +You can view all the translations keys available in the [Translations](form-adm-translations.md) form. + + +### ayTime + +Formats a raw DateTime stamp into a short time only (no date) in the locale format of the Client or server / report default + +```{{ ayTime startDate }}``` + + +## Report data objects + +When a report template is processed, business object data is provided to the template along with other data. The exact object provided is as follows: + +```{ + ayReportData:[...array business object data...], + ayClientMetaData:{...object Client / User data...}, + ayServerMetaData:{...object server data... } + } +``` + +### ayReportData + +This is the main business object data provided to the template. + +It is *always* provided as an Array. In the case of a single object it will be an array of one, in the case of multiple objects it will be the same object definition but repeated for each object. + +For example if you are reporting off a Customer you would design a report that can handle one or multiple Customer objects so that the same report can be used when viewing a single Customer or a whole list of Customers. + +The data provided to the report consists of the same fields visible in the user interface when editing that record and in addition, where appropriate, extra fields to bring in commonly required data from other objects that are linked. + +#### Localization + +Localization is a *Client* responsibility in AyaNova. + +The server is Locale agnostic and doesn't normally process data into localized format but rather leaves that to the Client AyaNova software running on the web browser. + +However, because reports are processed *at* the server, the server uses the locale information provided by the Client when requesting the report in the ayClientMetaData property in conjunction with the Helpers provided to localize the data to display according to the Client that requested the report. + +Some reports are also generated outside of a Client session, for example when sending a report as an attachment in an email notification, in that case report defaults will be used. + +Date and time values: raw Date and time values are provided in the ayReportData object in UTC / GMT time and [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) universal time format. Helpers are used to display this data in the Client default format. + +Currency / decimal: currency and decimal number values are provided in simple decimal notation and formatted for display using a Handlebars helper and the Client default format. + +Translations: translated text is displayed in the current logged in Client User's default Translation setting using a Handlebars helper. ## ayClientMetaData When a report is rendered some settings from the Client browser are sent along with the report and are used as required to localize date, time and currency display formats as well as the current logged in User's API credential Bearer token and some other Client dependent settings. You can see what data is provided by using the ayJson helper as in the example above on the report. As of the time of this writing the current values provided are: + ``` -ayClientMetaData: { "UserName": "AyaNova username", "Authorization": "Bearer eJhbGciO...token...data...hb9JyjcWl3Tib", "TimeZoneName": "America/Los_Angeles", "LanguageName": "en-US","Hour12": true, "CurrencyName": "USD", "DefaultLocale": "en" } +ayClientMetaData: +{ + "UserName": "AyaNova username", + "Authorization": "Bearer eJhbGciO...token...data...hb9JyjcWl3Tib", + "TimeZoneName": "America/Los_Angeles", + "LanguageName": "en-US", + "Hour12": true, + "CurrencyName": "USD", + "DefaultLocale": "en" +} ``` ## ayServerMetaData