Retail Save Rule
A rule a record must meet when it is saved, applied by iVendNext itself. A manifest installs it.
Area: Your app: its install, its user and its doors · Why it is here: contract save_rules; recipe event_feed; recipe save_rules · Fields: 36
iVendNext's own description: A shop's own field rule, checked on every save of its record type: Desk form, import or API. Only a System Manager keeps these.
Read and write it
Every call runs as your app's own user, with its key in one header, at the retailer's own address. The user reads and writes only what its role allows: your app's user, and the rights the retailer gives it.
Read a list (only name unless you ask for fields):
curl -s "https://⟨site⟩/api/resource/Retail%20Save%20Rule?fields=%5B%22*%22%5D&limit_page_length=20" \
-H "Authorization: token ⟨api key⟩:⟨api secret⟩"
Read one, with its tables:
curl -s "https://⟨site⟩/api/resource/Retail%20Save%20Rule/⟨name⟩" -H "Authorization: token ⟨api key⟩:⟨api secret⟩"
Create one (the required fields first), if your app's role may:
curl -s -X POST "https://⟨site⟩/api/resource/Retail%20Save%20Rule" -H "Authorization: token ⟨api key⟩:⟨api secret⟩" \
-H "Content-Type: application/json" -d '{"rule_name": …, "record_type": …, "kind": …}'
Change one with PUT /api/resource/Retail%20Save%20Rule/⟨name⟩ and the fields you change; a table sent there replaces its rows, so send its existing rows too. All the record calls and their answers: the API reference.
Samples that use it
s22_customer_loyalty · s40_expiry_recall
Fields
Read from the product at POS 2.1.0.667 (till app 60147699c): its own fields, the fields iVendNext adds to it, and iVendNext's changes to any of them. Read-only fields are set by iVendNext; a hidden one is not on the form but can be read. Every record also has name (its id, in the address), owner, creation, modified, modified_by and docstatus (0 a draft, 1 submitted, 2 cancelled), all read-only.
| Field | Field name | Type | Required | Read-only | Hidden | Links to |
|---|---|---|---|---|---|---|
| Rule name | rule_name |
Data | yes | |||
| Record type | record_type |
Link | yes | DocType | ||
| Table | child_table |
Data | ||||
| Kind | kind |
Select | yes | one of: pattern, length, derived, unique_in_rows, threshold, required_when, locked_in_state, unique_across, role_for_action, count_per_day | ||
| Field | field |
Data | ||||
| Enabled | enabled |
Check | ||||
| When the rule is broken | mode |
Select | one of: refuse, flag | |||
| Sequence | sequence |
Int | ||||
| Message | message |
Data | ||||
| Shape | pattern_class |
Select | one of: alphanumeric, upper_alphanumeric, digits, letters, phone_e164 | |||
| Pattern | pattern |
Data | ||||
| At least (characters) | min_length |
Int | ||||
| At most (characters) | max_length |
Int | ||||
| Formula | formula |
Select | one of: scale, days_until, percent, sum_rows, count_rows, days_between | |||
| Rows of table | source_table |
Data | ||||
| Source field | source |
Data | ||||
| Second source field | source_b |
Data | ||||
| Factor | factor |
Float | ||||
| Offset | offset |
Float | ||||
| Decimals | decimals |
Int | ||||
| Must be | operator |
Select | one of: =, !=, >, >=, <, <= | |||
| Value | value |
Data | ||||
| Judge only when new or changed | judge_on_change |
Check | ||||
| Limit from record type | value_from_type |
Link | DocType | |||
| Limit from record | value_from_name |
Data | ||||
| Limit field | value_field |
Data | ||||
| Role field | roles_field |
Data | ||||
| Action | action |
Select | one of: submit, cancel | |||
| Roles that may pass it | bypass_roles |
Small Text | ||||
| When all of these hold | conditions |
Table | Retail Save Rule Condition | |||
| From these workflow states on | states |
Small Text | ||||
| Locked fields | locked_fields |
Small Text | ||||
| Within the same | scope_fields |
Small Text | ||||
| Counted per | scope_field |
Data | ||||
| Day from | day_field |
Data | ||||
| At most per day | cap |
Int |
Table: Retail Save Rule Condition
The rows of conditions. Each row also has idx (its place), parent, parentfield and parenttype.
| Field | Field name | Type | Required | Read-only | Hidden | Links to |
|---|---|---|---|---|---|---|
| Field | field |
Data | yes | |||
| Operator | operator |
Select | yes | one of: =, !=, >, >=, <, <=, is set, is not set, in | ||
| Value | value |
Data |