Articles on: For developers
This article is also available in:

Script Syntax

Scripts



A context object is passed to the script, which contains properties with data and methods. Some properties are read-only and cannot be changed, while others are used for writing (making changes).

There are three types of scripts:
Product – for changing product prices, availability, tags, and properties
Status – for changing product statuses
Analysis – for building product data views

General Data


Passed to scripts of all types.

Data

A read-only property containing general data from the system:
MainCurrency – system currency (USD, EUR, etc.)
Category – a dictionary with categories, the key string with the category’s ExternalId, the value is the category data {Id: Guid; ExternalId: string; Name: string; ParentExternalId: string; IsActive: boolean}
Contractor – a dictionary with contractors, the key string with the contractor's UnifiedName, the value is the contractor data {ExternalId: string; Name: string; Tags: string[]}
ProductPriceType – a dictionary with price types, the key string with the price type's UnifiedName, the value is the price type data {Id: Guid; Name: string; ExtensionData: string}
ContractorPriceType – a dictionary with contractor price types, the key string with Contractor.UnifiedName-ContractorPriceType.Code, the value is the price type data {Id: Guid; Name: string;}
PriceSet – a dictionary with price groups, the key string with the price group’s UnifiedName, the value is the price group data {Id: Guid; Name: string; UnifiedName: string}
Global – Dictionary <string, Dictionary<string, string>>

ContractorPrices

A read-only property that contains an array with contractor prices for the current product ReevaluationContractorPrice[]

ReevaluationContractorPrice type:
Code – contractor price code
Name – contractor product name
Url – contractor product link
Price – product price
Currency – currency for the product price
ParsedOn – parsing date and time (DateTime)
Contractor – contractor’s UnifiedName (unique short name which is set during the Contractor creation)
PriceSet – price group’s UnifiedName (unique short name which is set during the PriceSet creation)

Logs

A read-only property used for writing logs. Contains the Add(string message) method.

Iteration

A technical read-only property that represents the sequential number of the product during processing (e.g., first, second, third, etc.).

Methods

double? ConvertPrice(double? price, string fromCurrency, string toCurrency)
Converts the price from one currency to another.

ReevaluationContextPricesWrapper GetPrices(Func<ReevaluationContractorPrice, bool> predicate = null)
Retrieves contractor prices in the system currency. Optionally, it can pass a predicate for filtering.

ReevaluationContextPricesWrapper GetPrices(string currency, Func<ReevaluationContractorPrice, bool> predicate = null)
Retrieves contractor prices in a specified currency. Optionally, it can pass a predicate for filtering.

Type ReevaluationContextPricesWrapper
Contains a ReevaluationContractorPrice[] Values array with prices and methods: double? Min(), double? Max(), double? Avg(), int Count().

Product script



ProductOld

A read-only property with product data:
Price – a dictionary with product prices, the key is the UnifiedName of the price type, the value is the price (can be null)
Currency – a dictionary with product price currencies, the key is the UnifiedName of the price type, the value is the currency (can be null)
Property - a dictionary with product properties, the key is the UnifiedName of the property, the value is the product property value (can be null)
Tag – a dictionary with product tags, the key is the UnifiedName of the tag, the value is true or false
ExternalId – the product code in your system
CategoryId – category code in your system
Name – product name
Vendor – vendor name
VendorCode – article number
CreationTime – product creation date (DateTime)
Availability – UnifiedName of availability
Catalog – UnifiedName of the catalog
IsActive – product status (true/false)

Product

A property for writing:
Availability – UnifiedName of availability type
Price – a dictionary with product prices, the key UnifiedName of the price type, value = price (can be null).
Currency – a dictionary with product price currencies, the key UnifiedName of the price type; value = currency (can be null)
Tag – a dictionary with product tags, the key UnifiedName of the tag, value = true/false)
Property – a dictionary with product properties, the key UnifiedName of the property, value = property value (string)


Status script



ProductOld

A read-only property with product data, the same as in the Product script.

Product

A property for writing:
IsActive – true/false

Analysis


Consists of two scripts: columns and data. The script for calculating columns is executed once before the script for generating data for each product in these columns.

Columns

Columns – property contains a method for adding a column:
Add(string dataField, string caption, int width, string alignment = null, string band = null, bool isFixed = false)

Data

ProductOld – a read-only property with product data, the same as in the Product script
Cell – a dictionary for filling data in cells, the key DataField column’s and the value is a CellData object

CellData type contains properties:
Text – text in the cell
ToolTip – tooltip on hover
Background – background color
Color – text color
IconId – icon
IconColor – icon color
Href – link (if filled, the text will be displayed as a link)
Bold – true/false
Italic – true/false
TextDecoration – underline/line-through

Updated on: 28/08/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!