Formats
Format configurations define how Axon Ivy renders values of a specific type when
outputting them to users. You can define formats for all base types of
IvyScript, i.e. Boolean
, Date
, DateTime
, Time
, Number
, and
String
. Output any non-null values of those types as formatted
strings by calling the format("<format name>")
within any script.
Examples:
panel.label.text = in.selectedDate.format("long");
out.invoice.customerNumber = wsData.customer.format("customer_id");
For several types, there are already default formats available, which can be
passed to format(X)
:
Number
: number, integer, currency, percentTime
,Date
andDateTime
: short, medium, long, full
Editor
Formats are defined in config/formats.yaml
of your project. The
following listing shows all available properties:
1Formats:
2
3 # for strings you can only define script
4 # whereas value will be replaced with the value itself
5 String:
6 myStringFormat:
7 Script: '"Hello " + value"'
8
9 # for boolean you can only define script
10 # whereas value will be replaced with the value itself
11 Boolean:
12 myBooleanFormat:
13 Script: '"Hello " + value"'
14
15 Number:
16 # will truncate decimal places
17 myNumberIntegerFormat:
18 Type: integer
19
20 # can be used to define integer and fraction part
21 myNumberNumberFormat:
22 Type: number
23 IntegerDigits: 3
24 FractionDigits: 4
25 Grouping: true
26
27 # for currency
28 myNumberCurrencyFormat:
29 Type: currency
30 IntegerDigits: 3
31 FractionDigits: 4
32 Grouping: true
33
34 # for percent
35 myNumberPercentFormat:
36 Type: percent
37 IntegerDigits: 3
38 FractionDigits: 4
39 Grouping: true
40
41 # do whatever it needs with script
42 myNumberScriptFormat:
43 Type: script
44 Script: '"Hello " + value"'
45
46 # use a pattern
47 myNumberPatternFormat:
48 Type: pattern
49 Pattern: "#,#00.0#"
50
51 # for date you can define a script or a pattern
52 Date:
53 myDateScriptFormat:
54 Type: script
55 Script: '"Hello " + value"'
56
57 myDatePatternFormat:
58 Type: pattern
59 Pattern: "EEEE dd. MMMM yyyy"
60
61 # for datetime you can define a script or a pattern
62 DateTime:
63 myDateTimeScriptFormat:
64 Type: script
65 Script: '"Hello " + value"'
66
67 myDateTimePatternFormat:
68 Type: pattern
69 Pattern: "EEEE dd. MMMM yyyy, HH:mm:ss"
70
71 # for time you can define a script or a pattern
72 Time:
73 myTimeScriptFormat:
74 Type: script
75 Script: '"Hello " + value"'
76
77 myTimePatternFormat:
78 Type: pattern
79 Pattern: "HH:mm:ss:SSS"