How do I? articles
 
Library All Articles

Common

Identify groups of customers See what customers purchase most Delete Customers Understanding Reports Maintaining Departments

Products

Barcodes Loading Products Product Fields Shelf Labels Manufacturing

Pricing

Overview Create groups or bands of prices

Customers

Accounts

Marketing

Offer a discount coupon

Selling

Type a Sale Display Messages

Stores

Geo Coding

Questions

Working with Historic Sales Track Serial Numbers

Stock Control

Manufacturing Receive from scans

Advanced & Rare

Backdate Sales Edit Historic Sales Use Formulas

Formulas

Fieldpine allows you to enter formulas in several places to control operation. This goes beyond simply using formulas for pricing and monetary use, to also using formulas as control expressions. For example, you can specify a "formula" to control if products are visible at specific POS terminals.

The expression engine is originally based on Blake Madden's tinyexpr++, which itself is based on Lewis Van Winkle's TinyExpr

Syntax

Formulas are specified as text strings, without the leading Y= concept. For example the expression Y=A+B is simply entered as "A+B".

Examples

7 + 3
(10) Adds two numbers
cat + dog
Adds two numbers where "cat" and "dog" are variables at the time of execution.
or(cat,dog)
Returns TRUE (1) if either "cat" or "dog" is TRUE. Otherwise it returns FALSE. This can also be written as "( cat | dog )" but it cannot be written as "cat or dog"
if( (cat+dog+Perth+Sydney >= 2), 1, 0)
Returns true (1) if two or more of the variables, { cat, dog, Perth, Sydney } are true. If the current environment only has one variable set, the result is FALSE (0). This might be used to provide a threshold rule where a minimum number of conditions are required.
if ( (fdl$date(now) > fdl$date(1-dec-2022) | pilotsite), 1, 0)
Return true if the current date/time (localtime) is greater than 1-dec-2022. Return true if the variable "pilotsite" is true. Otherwise return false.

The function fdl$date() is used to load various dates and times, see below

Runtime Execution Notes

Formulas are typically used to decide if something should happen or not. This is a true/false type decision. However, you may need to use variables that aren't defined, which would cause the expression to be invalid. Therefore in most places, a value of zero will be added for unknown variables. This means you can define a formula such as

= or(Perth,SydneyB,activecustomer.female)
The variable "activecustomer.female" will only have a value if the current sale has a customer attached. If no customer is attached, then the result of this formula would be FALSE, even if the variable "Perth" is true. However, by forcing the variable "activecustomer.female" to zero, the formula can and will return TRUE for Perth users.

Function fdl$date()

This function converts a date/time to a numeric value that can be used for comparisons. It can convert either literal dates or selected keywords

KeywordResult
fdl$date(today)Current Date without time. Or to be more precise, time is set to 00:00 (beginning of the day)
fdl$date(now)Current date and time
fdl$date(todayutc)Current UTC Date without time
fdl$date(nowutc)Current UTC date and time
fdl$date(yesterday)Equivalent to today - 1day
fdl$date(tomorrow)Equivalent to today + 1day
fdl$date(month) Date at first of the current month, without time. If the keyword month has a -N or +N after it, the date is moved back/forward N months.
For example if fdl$date(today) is 23 August, then fdl$date(month) is 1 August, and fdl$date(month-2) is 1 June
fdl$date(year) Date at the beginning of the year. If the keyword year has a -N or +N after it, the date is moved back/forward N years.
All others Interpret the value as a literal date/time. The prefered format is DD-MMM-YYYY HH:MM ( 23-Aug-2017 14:54 )

Do not use the formats DD-MM-YYYY or MM-DD-YYYY (where month is a two digit number) as it is ambiguous as to which format is being used. The function will decode this format, but you should consider this translation as luck and subject to change. Contact support about this and you will be told to use a different format.

You can use the format YYYY-MM-DD

The numeric value of the date/time is not intended to be used to calculate time differences. You can use Dx > Dy to compare two dates. You cannot add/subtract two dates to try and get a time difference. The value of Dx - Dy does not generally contain a useable value. If the result of Dx - Dy is more than 24 hours though, the value will be >= 1