/
Business Rule: Filename Parser

Business Rule: Filename Parser

Goal: parse the filename of items on upload and tag the Content Items in Picturepark with the product tag

Analysis

  • a layer which can be assigned to the content (“Product information” layer)

  • list of products and their code (“Products” list)

  • “rule” to split the filename into product code and “other”

Prerequisites

Cache

Create a cache for Products. This cache will be used for looking up the correct tag to assign. 

  1. Switch to Cache

     

  2. Create List Item Named Cache

    1. Schema ID: Products

    2. Key fields: Code (the one we will match with the filename information)

    3. Name: ProductListCache

VIDEO: How To Switch To Caches

Regular Expression

Regular expression to split the file name into product code and other values.

  • Regex: (?<productCode>^[0-9]{2} [0-9]{3} [^-]*)-(?<filename>.*)

    • Input: 01 747 7715 7754-Set_HighRes_4035.jpg

    • Output:

      • productCode: 01 747 7715 7754

      • filename: Set_HighRes_4035.jpg

Online tool to test & validate regular expressions: www.regexr.com

  • Make sure PCRE is selected in the top right corner

  • Switch between Details and Explain tab

Business Rule Setup

Trigger

The trigger point (check Triggers in Business Rule Settings):

  • Should trigger on content upload -> Action Create

  • We want to modify the Content Item document -> Execution scope Main doc

Condition

Goal: Rule should execute for images only and only if the filename matches our regex

  • Two conditions -> start with an AND condition

  • AND

    • Content schema condition -> Image (only do this for images)

    • Match Regex condition

      • Field path: imageMetadata.fileName

      • Regex: (?<productCode>^[0-9]{2} [0-9]{3} [^-]*)-(?<filename>.*)

      • Store in: parsedFilename

You can find additional information on the fieldpath and the trigger field specialties in the explanation of fields in Picturepark. 

Transformations

  • Perform lookup of the first part of filename against Products list

  • Create a new transformation group

    • Inputs: $parsedFilename$

    • Store In: product

    • Transformations

      • Take Dictionary Value (key: productCode)

      • Lookup Cache

Action

Goal: Assign Product information layer with required field Product

  • Assign Layer Action

    • LayerId: Product information

    • Default values:

      { "product": { "_refId": "$product$" } }



Related content

Assign Value Action
Assign Value Action
Read with this
Filename parsing for various lists
Filename parsing for various lists
More like this
Business Rule: File Name Parsing to Fieldsets
Business Rule: File Name Parsing to Fieldsets
More like this
String contains condition
String contains condition
More like this
String contains condition
String contains condition
More like this
String contains condition
String contains condition
More like this

FotoWare Switzerland AG - CH-5033 Buchs - Switzerland
https://picturepark.com - support@picturepark.com
© 2023 FotoWare Switzerland AG