Tableau Migration SDK 5.1.1
  • Articles
  • Code Samples
  • Python API Reference
  • C# API Reference
Show / Hide Table of Contents
  • Filters
    • Filter projects by name
    • Filter users by SiteRole
    • Filter Custom Views by 'Shared' flag
  • Mappings
    • Username email
    • Rename projects
    • Change projects
  • Transformers
    • Add tags to content
    • Encrypt Extracts
    • Adjust 'Start At' to Scheduled Tasks
    • Change default users for Custom Views
    • Action URL XML Transformer
  • Post-Publish Hooks
    • Update permissions
  • Bulk Post-Publish Hooks
    • Bulk logging
  • Batch Migration Completed Hooks
    • Batch migration logging
  • Migration Action Completed Hooks
    • Migration action logging

Code Samples

Once you have started building your migration using the example code in C# or Python, you may want to further customize your migration using hooks. This section provides code samples to assist you.

Learn more about hooks here.

Hook Registration

To use hooks, you need to register them with the plan builder.

The process of registering hooks differs slightly between C# and Python, as described below.

  • Python
  • C#

In Python, injecting an object into the class constructor is not supported, and in most cases, it is unnecessary.

To register a Python hook object, simply create the object and add it to the appropriate hook type collection.

Generic Form: plan_builder.[hook type collection].add([hook object])

Example:

plan_builder.filters.add(UnlicensedUsersFilter)

In C#, the hook object should be registered with Dependency Injection (DI). This allows hooks to have any object injected into the constructor without concern for the source of the object.

Learn more about dependency injection.

To register your hook object with the dependency injection service provider, simply add it.

Generic Form: services.AddScoped<[Object type]>();

Example:

services.AddScoped<UnlicensedUsersFilter>();

Once the hook is registered with DI, it must be added to the appropriate hook collection.

Generic Form: _planBuilder.[hook type collection].Add<[object name], [hook type]>();

Example:

_planBuilder.Filters.Add<UnlicensedUsersFilter, IUser>();
  • Edit this page
In this article