Form Data Provider Add-In

A Form Data Provider add-in can be used to provide a combo box or radio button control with predefined or dynamic values. Once installed, an add-in provider is visible under the data source tab when viewing the control's properties.

Form Data Provider add-ins are available for Content Manager and Template Manager applications.

How to build

Follow these steps to create a Form Data Provider add-in:

  1. Create a new class library using Visual Studio that targets the .NET Framework version used by the Portal that will host the add-in.
  2. Add one of the following NuGet package to the project:
  • Xpertdoc.ContentManager.AddIn
  • Xpertdoc.TemplateManager.AddIn
  1. Locate the class ContentMetadataFormDataProviderAddIn that was added by the Nuget package installer.
  2. Update the method GetItems with the code that will return the available values for the control. This code can reference the passed in context.Metadata property if values need to be dynamically generated.

Here's a sample GetItems implementation:

/// <summary>
/// Gets the items.
/// </summary>
/// <param name="context">The context.</param>
/// <returns>The items of the data provider.</returns>
public IDictionary<string, string> GetItems(
  IContentMetadataFormDataProviderContext context)
{
  if (context == null)
  {
    throw new ArgumentNullException(nameof(context));
  }

  ContentMetadataFormDataProviderMetadata metadata;
  using (var reader = new StringReader(context.Metadata))
  {
    metadata = (ContentMetadataFormDataProviderMetadata)
      MetadataSerializer.Deserialize(reader);
  }

  if (metadata.ValueKind == "Odd")
  {
    return new Dictionary<string, string> 
    { 
      { "key1", "Value 1" }, 
      { "key3", "Value 3" } 
    };
  }
  else
  {
    return new Dictionary<string, string> 
    { 
      { "key2", "Value 2" }, 
      { "key4", "Value 4" } 
    };
  }
}

Parameters can be passed to the add-in via the Metadata property. To define custom properties, add them to the ContentMetadataFormDataProviderMetadata class.