8.3. Custom Classification

Follow

Custom classification is a powerful feature to allow specific items to be assigned to a Target Content Type independent of what their source content type is.  Customer defined criteria can be specified to identify such items.  For example, a ‘HR Items’ custom classification can be defined as any source items that have 5 digit number in the Name metadata field.  Just like normal content types, these custom classifications then need to be mapped to a suitable target content type.

Example #1:

Scenario: In a File system migration, most files should be migrated ‘as is’ but for those items located in a specific folder the filename will contain an employee ID and there is a requirement for this employee ID to be used to populate a target metadata field for these items. 

Solution: In this case, Custom Classification ‘HR Items’ can be created and used to detect these specific items and mapped to the target content type ‘HR Items’.  Afterwards, using the target metadata mapping feature for the ‘HR Items’ a target metadata field ‘EmployeeID’ can have a Function associated with it which would execute a customer written PowerShell script to process the filename source field parameter passed into it and parse it to return the employee ID which then populates the EmployeeID field.

In this way then, Custom Classification is being used to select the items which need to have their metadata properties processed in a different way to other items of the same source content type.

Example #2:

Documents and Images in ShareFile are saved as Documents, whereas SharePoint Online has a specific Content Type Image.   Simply mapping items of Source content type Documents to Image target content type would mean images AND documents from ShareFile being migrated as Documents.  Instead we need a way to identify these images that are currently classified as Documents in ShareFile and process their metadata properties differently.

As many Custom Classifications can be created as required. 

 

8.3.1.  Creating a Custom Classification

In the steps below, a new Custom Classification will be created called ‘Custom Images’ and is defined by items in the source with file extension of .jpg or .png.  This will be named ‘Custom Images’ and can then be mapped to the SharePoint target content type ‘Image’.

To Add/Edit a Custom Classification select Migration Preparation Phase > Content Type & Metadata Mapping.

Click Picture4.png next to Custom Classifications to open Add/Edit Custom Classification page.

 

Picture113.png

 

Custom Classifications can be edited or deleted by clicking on Picture114.png respectively.

The Add/Edit Custom Classification screen is displayed to define a new Custom Classification.

 

Picture115.png

 

Classification Name: This is the name for this custom classification.

Base Content Type: When creating a classification, select an existing content type to use as a template for source metadata fields that will be available for mapping to target.

List of Variable available for Scripting: The variables listed will contain relevant source metadata properties based upon the selected base content type and can be used by the script. Each will then be available as their name in the script, so Title attribute is stored in $Title variable for example.

Specify test values: When developing the script, use this to specify test parameter values to confirm the PowerShell is working as expected.

Script: This is where the PowerShell script should be written. The script should evaluate the parameters passed to it and should return $true if the item should be assigned the associated custom content type, otherwise return $false.

 

Click Evaluate to run the PowerShell using the test values provided.

The output of the script will appear in the Function Testing output window.

Once testing is complete, use Save option to create the new custom classification.

 

The Add/Edit Custom Classification script should evaluate to True for custom classification to work properly. Anything that evaluates to False will skip the added Source classification settings.

Following the steps above, the Custom classification ‘Custom Image’ is then available to map to an appropriate Target Content Type (e.g. Image)

Note: It’s essential to review the metadata mapping once the custom classification is mapped to a target content type.

 

Note: Custom classifications will only get executed if they have been mapped to a target content type.

Custom Classification Execution

The actual execution of these classification scripts will occur when running the Step 2 – Classify in the Migration Phrase. For each item, each of the script(s) will be executed till one returns a value of ‘True’.  So for example if there are 3 Custom Classifications, then Step 2 Classify - Assign Target Content Type will run each script, passing to it the relevant item metadata values till one of the scripts returns ‘True’ or all scripts have been executed for the item. If none of the scripts return ‘True’ then the original Source Content Type is assigned to the item.

Note: The order in which the classification scripts are executed against each item is random.  That means it’s essential that these scripts do not ‘overlap’ one another i.e. two scripts could potentially return ‘True’ for the same item.  When developing a script to identify an item if there are other custom classifications, it may be necessary to update those scripts to ensure that they will exclude such items.

 

8.3.2.  Custom Classification Scripting Objects

The following objects can be used in the PowerShell script to classify items.

  • MigrationItem
  • SI - The source representation of the item 
  • ItemName - The name of the item as shown in the user interface. 
  • MimeType - The file extension of the item. 
  • Uri - The logical path of the item. 
  • AlternateUri - The path to the binary if the item is a file. 
  • GroupId - The document identifier that is common across all document versions. 
  • VersionLabel - The major version. 
  • SubVersionLabel - The minor version. 
  • EntityCategory - 0 for containers, 1 for files and links. 
  • EntityType - File, Link or Folder. 
  • ContentType - The content type classification of the item. 
  • ItemSize - The size of the content (in bytes). 
  • Level - The depth of the item in the folder tree. 
  • HasUniqueSecurity - Whether the item has security, information assigned

Example Classification Scripts

 

Description Example Script
Classifies Media files based upon Video or Audio content type

$result = $FALSE

If ($migrationItem.SI.ItemName)

{

$result =

$MigrationItem.SI.ContentType -eq 'Video' -or

$MigrationItem.SI.ContentType -eq 'Audio'

}

  • $result
Classifies Image items based upon file extensions (png,jpeg,jpg,tiff or bmp)

$result = $FALSE

If ($MigrationItem.SI.ItemName)

{

$result =

$MigrationItem.SI.ItemName.Contains(".png") -or $MigrationItem.SI.ItemName.Contains(".jpeg") -or $MigrationItem.SI.ItemName.Contains(".jpg") -or $MigrationItem.SI.ItemName.Contains(".tiff") -or $MigrationItem.SI.ItemName.Contains(".bmp")

}

$result

Classifies items based upon size and example of using Logging.

$result = $FALSE

if ($MigrationItem.SI.ItemName)

{

   if ($MigrationItem.SI.ContentType -eq 'File')

           {

                 if ($MigrationItem.SI.ItemSize -gt 1048576 )

                  {

                         $Log.DebugFormat("Large Item sized {1} for item {0}",                                      $MigrationItem.SI.Uri,$MigrationItem.SI.ItemSize)

                          $result = $true    

                   }

                  Else

                  {

                             $Log.DebugFormat("Small Item sized {1} for item {0}", $MigrationItem.SI.Uri,$MigrationItem.SI.ItemSize)            

                    }

         }

 }

$result

Classifies all files to a single content type

If ($MigrationItem.SI.EntityCategory -eq 1)
{

         return $true;

}
else
{

          return $false;

}

 

Was this article helpful?
0 out of 0 found this helpful

Comments