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$"
      	}
      }
      CODE