Validation Rule Types - Precisely_EnterWorks - EnterWorks - 11.0

EnterWorks Guide

Product type
Software
Portfolio
Verify
Product family
EnterWorks
Product
Precisely EnterWorks
Precisely EnterWorks > EnterWorks
Version
11.0
Language
English
Product name
Precisely EnterWorks
Title
EnterWorks Guide
Copyright
2024
First publish date
2007
Last updated
2025-01-07
Published on
2025-01-07T07:44:20.997000

These are the types of validation rules.

Rule Type Definition Notes
Bulk Callout A bulk callout validation rule is a SQL query-based validation that is performed once on the set of records being validated. See Bulk callout.
Calculate Concatenates values from multiple attributes. This is not actually a validation rule. The calculation is applied when a record is saved.
Call Out Java-based process that performs a specific validation on the record (and the assigned attribute). Some callout validation rules are pre-defined and available for immediate use. The majority of the callout validation rules are developed for a specific EnterWorks implementation. See Callout
Hierarchy Validation Deprecated.
Normalization Deprecated.
Pre-Save Callout See Pre-save callout. See Pre-save callout.
Simple Simple validation rule where the designated operation (and possible values) are applied to the assigned attribute. This is the most common validation rule and it is used to perform validations such as an attribute has to have a specific value or it has to be empty.
UCC GTIN Algorithm Verifies the value conforms to the UCC GTIN format.
UCC GLN Algorithm Verifies the value conforms to the UCC GLN format.
UCC UPC-12 Algorithm Verifies the value conforms to the UCC UPC-12 format.
UCC UPC-11 Algorithm Verifies the value conforms to the UCC UPC-11 format.
VTL-like Pre-save callout that runs a VTL script to update the record. This is not a validation rule but a pre-save callout that will alter the repository record as it is being created or updated.

Bulk callout

A bulk callout validation rule is a SQL query-based validation that is performed once for the group of records being validated, such as:

  • Individual record: the SQL is limited to just that record.
  • Saved set: the SQL is limited to the records in the saved set.
  • Full repository: the SQL query is run against the entire repository.

In each case, the results of the query are the records that violate the rule, which are listed in a temporary table. They are placed in the table so that when each record in the group is being validated, the temporary table is consulted instead of running the SQL again. When each record is validated for its other rules, the error table is consulted for any bulk callout violations. If there are any, their messages are added to the list of errors for that particular attribute.

The basic interface is that the callout needs to return one row for each record that has an error. The first column of the row is the internal ID of the record and the second column is the error message. The query itself needs to be formulated to find and return the offending rows.

Each query should be wrapped by the following outer query:

SELECT InternalRecordId, ErrorMessage
From (
<<… Actual query here >>
) as T1 WHERE 1=1

Note that EnterWorks references repositories by using their name in the default language, which is English. Also, the column names of the error table cannot be changed.

In the examples given below:

  • The repository named Item_Staging contains columns whose restricted names are Manufacturer, Manufacturer_Name, and SKU_Group.
  • The repository named PIM_MarketingAd_Staging has columns whose restricted names are Marketing_Ad_ID, Marketing_Ad_ID, and Image_Context.

Example queries:

  1. Item_Staging records must have Manufacturer
    select InternalRecordId,
    cast(Manufacturer as nvarchar(30)) + ' has no reference in Manufacturer repository' as
    ErrorMessage 
    from Item_Staging where Manufacturer is not null 
    and InternalRecordId not in 
    (select i.InternalRecordId from Item_Staging i inner join Manufacturer b on
    i.Manufacturer=b.Manufacturer_Name)
  2. All Item_Staging records require the same SKU_Group:
    select m.InternalRecordId, 'SKU Group:'+m.SKU_Group+' must have the same
    Taxonomy:'+m.Taxonomy as ErrorMessage
    from Item_Staging m, (select distinct a.InternalRecordId internalId from Item_Staging a
    inner join Item_Staging b on a.SKU_Group=b.SKU_Group
    where a.SKU_Group != 'DISCONTINUED' and a.Taxonomy != b.Taxonomy) t1 where
    m.InternalRecordId=t1.InternalId
  3. Records in PIM_MarketingAd_Staging must have a Main image: 
    select InternalRecordId,
    'Marketing Ad: ' + Marketing_Ad_ID + ' has no Main image' as ErrorMessage
    from PIM_MarketingAd_Staging  
    where InternalRecordId not in  
    (select ma.InternalRecordId from PIM_MarketingAd_Staging ma inner join DAMLink dl on
    ma.Marketing_Ad_ID=dl.PK1
    where dl.Image_Context = 'Main')

If a bulk callout validation rule is to be conditionally applied, the conditions for that application must be encoded in the SQL – the rule conditions will be ignored. This is because those conditions are based on the current record, but the bulk callout must validate all records in the repository or saved set.

Callout

A callout is a Java-based process that performs a specific validation on a record and the assigned attribute. Some callout validation rules are predefined and available for immediate use. The majority of callout validation rules are developed for a specific EnterWorks implementation.

The following callout rules are predefined in EnterWorks:

  • AttributesCalc
  • AttributesPriceUpdate
  • AttributesSearchAndUpdate
  • AttributesSearchAndCalculate
  • CheckAttributeCodeSetName
  • IsLengthLessThan
  • MatchesPattern: This callout compares the value to a REGEX pattern. If the value does not match one of the defined patterns, the attribute is flagged as invalid. A common application is to define the different formats for a phone number (for example, 1 (909) 555-1212, (714) 555-1212 x 1234, or 818-555-1212)
  • NoBlanks: This callout flags a value if it contains any spaces
  • NoInvalidCharacters: This callout flags a value as invalid if it contains any of the designated characters.
  • ValidReference: This callout flags a record as invalid if a corresponding record is not found in a linked repository. This callout has been supplanted by a bulk callout which is a more-efficient.
  • ValidCharacters: This callout flags a value as invalid if it contains anything but the designated characters
  • ValidDimensions
  • PIMWebServiceGetRepoAttrData
  • UpdateDistinctChildValues
  • UpdateParentWithDistinctChildValues
  • <custom>: Custom callout validation rules can be implemented to perform any needed specialized validation, providing those callouts follow the prescribed interface in the form of a Java class. Examples of callout rules:
    • Inheritance: The outcome of the validation is dependent upon the content of a linked parent record according to configured inheritance rules
    • Comparison to data outside of EnterWorks, such as using an API to access a web service. While such operations are possible, they are very expensive in terms of performance impact.
    • Complex logic that cannot be expressed in SQL (bulk callout) or simple validation rule. Many of the callouts listed above originated as complex rules needed for an implementation but were recognized as having general applicability so they were assimilated into the product.

Pre-save callout

Pre-save callouts are not a validation rule; they are used to perform a pre-save calculation on the record before the record is created or updated. For example, a pre-save callout could conditionally define a default value for an attribute or calculate a primary key based on other attribute values. If it is a compiled class, it may define a primary key using data in an external table or repository, for example, selecting a number from a pool of available numbers, then removing the number from the pool.

Pre-save callouts include:

  • VTLUpdatePreSaveCallout – updates the record using the VTL script defined in the callout properties.
  • AttributeVTLCaclulatePreSaveCallout
  • PriceCopyPreSaveCallout
  • AttributesSearchAndUpdatePrice
  • GroovyPreSave – runs a Java-based Groovy script defined in the callout properties.
  • NodeJSPreSave
  • <custom> - any Java class that follows the pre-save callout interface can be implemented to perform a pre-save operation.