Repository navigation
Expand file tree
/
Copy pathcel-predicates-formulas.json
More file actions
75 lines (75 loc) · 5.28 KB
/
Copy pathcel-predicates-formulas.json
File metadata and controls
75 lines (75 loc) · 5.28 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
{
"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 whose `expression` is CEL via the `F` tag. The text formula 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": "Applies the mechanical legacy → CEL table: `P`isBlank(record.po_number) && record.amount > 10000 && record.status != 'draft'``, noting that a `script` validation is inverted (it FAILS when the expression is true, so keep the failing condition) and that `record.amount > 10000` on a declared-nullable field needs an explicit `record.amount != null &&` guard or the publish gate rejects it.",
"files": [],
"assertions": {
"must_contain": ["isBlank(", "&&", "record.", "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 `new Date()` / `Date.now()` (the determinism gate: two `os build` runs must be byte-identical). Days remaining is `daysBetween(today(), record.close_date)` — never `record.close_date - today()` (a duration stored as `{}`) and never `today() + 45` (date arithmetic 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 whose predicate dominates the comparison with explicit null tests: `record.start_date != null && record.end_date != null && record.end_date < record.start_date`; a `has()` guard does not satisfy the publish-time 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": "Both are predicates over the STORED value: 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."]
}
}
]
}