Repository navigation
Expand file tree
/
Copy pathcel-predicates-formulas.json
More file actions
145 lines (145 loc) · 10.6 KB
/
Copy pathcel-predicates-formulas.json
File metadata and controls
145 lines (145 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
{
"skill_name": "objectstack-formula",
"evals": [
{
"id": 1,
"prompt": "Add a `full_name` formula on `contact` built from salutation, first name and last name, and a `margin_pct` formula on `deal` = (revenue - cost) / cost * 100.",
"expected_output": "Two `type: 'formula'` fields, `expression` under the `F` tag. The text one coalesces every nullable operand — `F`coalesce(record.salutation, '') + ' ' + coalesce(record.first_name, '') + ' ' + coalesce(record.last_name, '')`` — because `null + 'foo'` throws. The numeric one guards the divisor: `F`coalesce(record.cost, 0) > 0 ? ((coalesce(record.revenue, 0) - record.cost) * 100) / record.cost : 0.0``.",
"files": [],
"assertions": {
"must_contain": ["F`", "coalesce(", "record."],
"must_not_contain": ["{record.", "CONCAT("]
}
},
{
"id": 2,
"prompt": "Translate this Salesforce validation rule into ObjectStack: AND(ISBLANK(po_number), amount > 10000, NOT(ISPICKVAL(status, 'draft'))).",
"expected_output": "By the legacy → CEL table plus the null guard, `P`isBlank(record.po_number) && record.amount != null && record.amount > 10000 && record.status != 'draft'``; a `script` validation is inverted (it FAILS when true, so keep the failing condition), and `record.amount > 10000` on a nullable field needs the explicit `record.amount != null &&` guard or the publish gate rejects it.",
"files": [],
"assertions": {
"must_contain": ["isBlank(", "&&", "record.amount != null", "P`"],
"must_not_contain": ["{record.", "ISBLANK(record."]
}
},
{
"id": 3,
"prompt": "Run an automation only when a support case has just become `escalated` — on single updates and on bulk updates alike.",
"expected_output": "Writes it once as `P`previous.status != 'escalated' && record.status == 'escalated'``: `record` is the post-write state (true on every later update too), so only `previous` says \"just became\"; `previous` is bound per row on `before*`/`after*` update events, bulk too. On insert `previous` is `null`: the `previous.status` read faults and aborts the write, so to run on inserts guard with `previous != null &&`.",
"files": [],
"assertions": {
"must_contain": ["previous.status", "record.status", "!="],
"must_not_contain": ["ISCHANGED(", "{previous."]
}
},
{
"id": 4,
"prompt": "Demo opportunities should close 45 days after the package is installed, and a formula should show how many days remain until close.",
"expected_output": "Seed value as a CEL envelope, `close_date: cel`daysFromNow(45)``, never a JS `Date` / `Date.now()` (two `os build` runs must be byte-identical). Days remaining is `daysBetween(today(), record.close_date)` — never `record.close_date - today()` (the build refuses it) and never date arithmetic on `today()` (it faults).",
"files": [],
"assertions": {
"must_contain": ["cel`", "daysFromNow(", "daysBetween("],
"must_not_contain": ["new Date(", "today() + "]
}
},
{
"id": 5,
"prompt": "Hide `discount_reason` unless a discount amount was entered, and reject any `end_date` earlier than `start_date`.",
"expected_output": "`visibleWhen: P`record.discount != null`` (or `!isBlank(record.discount)`) on the field — `has(record.discount)` is not a null check: every declared field exists, so it is always true. The date rule is a `script` validation with explicit null tests ahead of the comparison: `record.start_date != null && record.end_date != null && record.end_date < record.start_date`; a `has()` guard does not satisfy the publish gate.",
"files": [],
"assertions": {
"must_contain": ["visibleWhen", "!= null", "record.end_date"],
"must_not_contain": ["conditionalRequired:", "{record."]
}
},
{
"id": 6,
"prompt": "Name `contract_version` records by their version number and the `kind` select, so a zh-CN reader sees `v2 · 清稿` and an en-US reader `v2 · Clean`.",
"expected_output": "A `type: 'formula'` `nameField`: `F`'v' + string(record.version_no) + ' · ' + label(record.kind)``. `label()` takes exactly `record.<field>` of a select field and reads its option label in the reader's locale (`''` for null). The stored value is the same in every locale, so a ternary over it with hard-coded strings cannot follow the reader.",
"files": [],
"assertions": {
"must_contain": ["label(record.kind)", "F`"],
"must_not_contain": ["== 'clean' ?", "{record."]
}
},
{
"id": 7,
"prompt": "Refuse a `contract_version` save unless its `kind` is the clean copy, and show `signed_at` only once `status` is signed.",
"expected_output": "A `script` validation `P`record.kind != 'clean'`` (it fails when true) and `visibleWhen: P`record.status == 'signed'``. The `label` macro evaluates only in a formula field; in a validation, `visibleWhen` or hook predicate it faults and aborts every write, so compare the stored value, never its option label.",
"files": [],
"assertions": {
"must_contain": ["record.kind", "visibleWhen", "P`"],
"must_not_contain": ["label(", "{record."]
}
},
{
"id": 8,
"prompt": "An `email_template` that mails one overdue notice per `contract`, the amount shown in that contract's own currency.",
"expected_output": "`{{ amount | currency:@currency_code }}` — only a mail template may read the code from the send's data. The stored code is three capitals (`EUR`), exactly as stored; when the template declares `variables`, the path must be one of them or lie under one. A bare path is refused, a literal code fixes one currency for every record, and no argument means the organization's default currency.",
"files": [],
"assertions": {
"must_contain": ["currency:@"],
"must_not_contain": ["currency:currency_code", "currency:USD", "currency:CNY", "| currency }}"]
}
},
{
"id": 9,
"prompt": "A record-change flow on `project` (start `triggerType: 'record-after-update'`, `objectName: 'project'`) escalates when the budget passes 200000. `budget` is a currency field with no `required` and no `defaultValue`. Write the edge condition from the decision node to the escalation branch.",
"expected_output": "`record.budget != null && record.budget > 200000`. The run binds every declared field of the trigger record, `null` when empty, and CEL has no `>` overload for null, so `os validate` and the runtime publish gate refuse the unguarded edge; at runtime the run would fail at that edge while the write that fired it still lands. A bare `budget > 200000` is the same field, and `os validate` refuses it too; and `has(record.budget)` is not a guard: a declared field holding null is still present.",
"files": [],
"assertions": {
"must_contain": ["record.budget != null", "record.budget > 200000"],
"must_not_contain": ["has(record.budget) && record.budget >", "{record."]
}
},
{
"id": 10,
"prompt": "On `event`, add a `start_day` formula that shows the day of the `start_at` datetime field as `YYYY-MM-DD` text.",
"expected_output": "`F`isoDate(date(record.start_at))``. A `date` / `datetime` field reads as its ISO text and `isoDate` takes a timestamp, so the build refuses the field handed to it directly (`date-text-call`); `date()` parses the text first. The same wrap goes ahead of a timestamp method: `date(record.start_at).getFullYear()`.",
"files": [],
"assertions": {
"must_contain": ["isoDate(date(record.start_at))", "F`"],
"must_not_contain": ["isoDate(record.start_at)", "{record."]
}
},
{
"id": 11,
"prompt": "On `quote_line`, `no_margin_reasons` is a select field with `multiple: true`. Add a `margin_note` formula that shows the selected reasons as text, in the reader's language.",
"expected_output": "`F`label(record.no_margin_reasons)``. On a multi-select, `label()` reads each selected value's option label in the reader's locale, in the order the record stores them, joined with `, ` (`No sales price, No customer` to an `en-US` reader); an empty selection reads `''`. No per-option ternary or extra field is needed.",
"files": [],
"assertions": {
"must_contain": ["label(record.no_margin_reasons)", "F`"],
"must_not_contain": ["joinNonEmpty", "{record."]
}
},
{
"id": 12,
"prompt": "On `loan`, add a `due_on` formula: 7 days after the `borrow_date` date field, as `YYYY-MM-DD` text.",
"expected_output": "`F`isoDate(addDays(record.borrow_date, 7))``. A `date` field reads as its `YYYY-MM-DD` text, and `timestamp()` parses only a full ISO instant, so the build refuses `timestamp()` over the field, alone or plus a duration (`date-text-call`). `addDays` shifts the date by whole days and `isoDate` keeps the result a date.",
"files": [],
"assertions": {
"must_contain": ["isoDate(addDays(record.borrow_date, 7))", "F`"],
"must_not_contain": ["timestamp(record.borrow_date)", "{record."]
}
},
{
"id": 13,
"prompt": "On `ticket`, `labels` is a `tags` field. Write the hook `condition` that is true when the ticket carries the `urgent` label.",
"expected_output": "`P`(has(record.labels) && record.labels != null && 'urgent' in record.labels)``. `labels` holds a list, so `record.labels == 'urgent'` compares the whole list with a scalar and is refused (`list-equality`): it answers `false` on every row. A hook `condition` is evaluated as CEL, so membership is `in`, behind a `!= null` guard, because `in` faults on a `null` list.",
"files": [],
"assertions": {
"must_contain": ["record.labels != null", "in record.labels", "P`"],
"must_not_contain": ["P`record.labels == 'urgent'", "{record."]
}
},
{
"id": 14,
"prompt": "On `ticket`, `labels` is a `tags` field. Write the sharing rule `condition` that matches the tickets carrying the `urgent` label.",
"expected_output": "`P`(record.labels != null && record.labels.contains('urgent'))``. A sharing rule's `condition` is compiled to a query filter, not evaluated as CEL, so membership is `.contains()`: `has()` and an `in` with the literal first do not lower there, and the rule would grant nothing. `record.labels == 'urgent'` compares the whole list with a scalar and is refused (`list-equality`).",
"files": [],
"assertions": {
"must_contain": ["record.labels != null", "record.labels.contains("],
"must_not_contain": ["P`record.labels == 'urgent'", "has(record.labels) &&", "{record."]
}
}
]
}