Available functions Main and auxiliary functions available when working with system objects. false W3sidGl0bGUiOiJBdXRvbWF0aW9uIiwidXJsIjoiL2RldmVsb3BlcnMvYXV0b21hdGlvbi8ifSx7InRpdGxlIjoiUGlwZUxhbmciLCJ1cmwiOiIvZGV2ZWxvcGVycy9hdXRvbWF0aW9uL3BpcGUtbGFuZy8ifSx7InRpdGxlIjoiRXhwcmVzc2lvbiBsYW5ndWFnZSIsInVybCI6Ii9kZXZlbG9wZXJzL2F1dG9tYXRpb24vcGlwZS1sYW5nL2V4cHJlc3Npb25sYW5ndWFnZS8ifV0= Automation /developers/automation/ ["developers","Automation"] ["developers","Automation","PipeLang"] developers

Available functions

Main and auxiliary functions available when working with system objects.

Working with data

NameDescription
date(date)Creates object DateTime on the basis of transmitted string, the format matches php function strtotime
date("2015-01-01")
date("1 day ago")
date("first day of this month 12:00") # if the time is not specified obviously, there will be used current time
time_interval(from, to, custom)Creates TimeInterval object based on transferred string values of time
When only parameter from is specified the interval with exact value of time will be created
It`s possible to specify only one interval limit
When parameter custom is transferred other parameters will be ignored and the interval will be with arbitrary string value
time_interval("18:00") # at 18:00
time_interval("16:00", "20:00") # from 16:00 to 20:00
time_interval("16:00", "") # from 16:00
time_interval("", "20:00") # to 20:00
time_interval("", "", "after 6 p.m") # arbitrary value in the form of the line
length(value)Returns length of transmitted string
length("string") # 6
unique(entity, field)Checks the uniqueness of the object by definite field
unique(customer, "email")
custom_field(entity, code)deprecated Returns the typified value of customer field
entity_by_code(entityName, code)Returns value of reference book by symbolic code
For selecting there are available object types: DeliveryType, DeliveryService, OrderMethod, OrderProductStatus, OrderType, PaymentStatus, PaymentType, Site, Status, StatusGroup, Store
entity_by_code('DeliveryType', 'delivery-type-10')
entity_by_id(entityName, id, idField)Returns content from the base by id
For selecting there are available object types: User, Site, Product, ProductGroup, Customer
When selecting the content Product it is possible to specify the identification field. Allowed values: id, externalId, article
entity_by_id('User', 4)
entities_by_ids(entityName, array ids, idField)Returns array of contents from the base by ids
For selecting there are available object types: Product, ProductGroup
When selecting the content Product it is possible to specify the identification field. Allowed values: id, externalId, article
entities_by_ids('Product', ['100', '101', '102'], 'externalId')
order_contains(Order order, array items)Takes order and items/item groups list and returns true if any item or item of any group is in order
customer_looked(Customer customer, items)Takes customer and items/item groups/order products list and returns true if customer has seen any item or item of any group
customer_looked_products_count(Customer customer)Function returns total quantity of items seen by the customer
replace(subject, placeholders)Replaces all occurrences in the original subject string according to the placeholders array.
replace("+79261234567", {"+7": "8"}) # 89261234567
replace(order.phone, {" ": "", "(": "", ")": ""})
offer_inventories(Offer offer, Site site, Store|array stores)Returns an array of inventories (array of Inventory objects) of the offer by stores
Accepts parameters:
Offer offer - offer object
Site|null site = null - store object, optional (only inventories for the store's warehouses will be returned)
Store[]|Store|null store = null - warehouse object or array of warehouse objects, optional (only inventories for the specified warehouses will be returned)
# Various ways to call the function
offer_inventories(op.offer)
offer_inventories(op.offer, order.site)
offer_inventories(op.offer, order.site, entity_by_code('Store', 'store-1'))
offer_inventories(op.offer, null, [entity_by_code('Store', 'store-1'), entity_by_code('Store', 'store-2')])
offer_inventories(op.offer, null, order.shipmentStore)

Auxiliary functions

NameDescription
user()Returns current user
user_status(User user)Returns the user status (free, busy, dinner, break)
user_status(order.getManager()) # free
user_online_status(User user)Returns the user online status (true or false)
user_online_status(order.getManager()) # true
hash(algo, data)Executes a one-way hashing of data with usage of specified hash-function (md5, sha1, sha256). The value returns as hex-tring lower case.
hash("md5", "test") # 098f6bcd4621d373cade4e832627b4f6
last_run(interval, triggerCode, findByEntity)Returns information about the last start of trigger; if trigger starts for the first time the function returns null , more details. Available only in triggers.
rand(min, max)Returns random whole number of specified range [min, max]
rand_string(length, alphabet)Returns random symbols sequence of specified length, containing only symbols of the specified set (alphabet). By default there is used set containing only english letters lower case and numbers.
rand_string(3)
rand_string(3, "a") # aaa
local_time(source, default)Local time according to current settings. Parameter source can be equals to CustomerAddress, CustomerPhone, OrderDeliveryAddress, StoreAddress or phone number as string.
local_time(customer.getAddress())
local_time(order.getPhone())
is_working_time(dateTime)Function checks whether the dateTime value is working time and returns result (true or false). As a dateTime the function can take DteTime object or string, whose format corresponds to php format of strtotime function. By default the current date and time is used.
is_working_time()
is_working_time('2015-01-01 10:00:00')
is_working_time(date('2015-01-01 10:00:00'))
is_working_time(order.getCreatedAt())
round(value, precision, method)Returns a rounded value with specified precision.
The first value is the number to be rounded, the second is the rounding precision (0, if to the whole), the third is the rounding mode (common is the usual mode, ceil always rounds up, floor always rounds down)
round(12.3456) # 12
round(12.3456, 2) # 12.35
round(12.3456, 2, "floor") # 12.34
round(12.3456, 0, "ceil") # 13.0
round(-1.5, 0, "ceil") # -1.0
is_valid_email(string email)Checks validity of an e-mail address. Returns true or false.
is_valid_email("user@mail.com") # true
is_valid_email("user") # false
Thank you for your feedback.
Was this article helpful?
No
  • The recommendations did not help
  • There is no answer to my question
  • The text is difficult to understand
  • I do not like the described functionality
Yes
Previous article
Supported Operators
Operators are a set of commands that are used when working with PipeLanguage. With them you can perform mathematical, logical and other operations with system data.
Next article
Available filters
List of filters that can be used to generate validations, triggers, and templates.