SDK: Text Merge Behavior
  • 19 Mar 2024
  • 2 Minutes to read
  • Dark
    Light

SDK: Text Merge Behavior

  • Dark
    Light

Article Summary

Version 7.x .NET Architecture Change

Overview

Text Merges can be given behavior with predefined inputs, limit whether or not inputs are visible to the user, and/or add additional actions in the Text Merge action menu.

Example

This example will demonstrate how to create a Text Merge behavior.

  1. Create a public class that inherits from DefaultTextMergeBehavior. This will provide three overridable methods to control the behavior of the Text Merge. These methods are:

    • public override void OnCreate(AbstractTextMerge merge) - use this method to set default input data for the text merge. The default behavior for this method is empty (No modifications are made on creation). Below is an example snippet showing how to add an input called Color to a text merge.
    • When a Text Merge with this override is created, it will have a piece of input data that shows up in the Designer. 
      public override void OnCreate(AbstractTextMerge merge)
      {
         if (merge == null)
             throw new ArgumentNullException("merge");
         merge.Input = new FlowInputDataDescription[] {
             new FlowInputDataDescription("Color", false, false, (DecisionsNativeType)typeof(string)) };
      }
      


    • public override bool ShowInputs()- use this method to hide the inputs from a Designer user. The default behavior for this method is true (inputs are shown to the user). Below is an example snippet showing how to hide the input data from the designer user.
    • When a Text Merge with this override is created, it will show up in the Designer with the input data hidden.
      public override bool ShowInputs()
      {
         return false;
      }
      


    • public override BaseActionType[] GetAdditionalActions(ElementRegistration elementRegistration, TextMerge textMerge)- use this method to add additional actions to the actions menu of the text merge. Below is a snippet showing how to add an action that will copy the Text Merge's name to the user's clipboard.
    • When a Text Merge with this override is created, it will show up in the Designer with an additional action displayed.
      public override BaseActionType[] GetAdditionalActions(ElementRegistration elementRegistration, AbstractTextMerge textMerge)
      {
         List<CopyTextAction> actions = new List<CopyTextAction>();
      
         actions.Add(new CopyTextAction("Copy Text Merge Name", "This use action to copy the name of this text merge to your clipboard", "Manage", elementRegistration.EntityName));
      
         return actions.ToArray();
      }


  2. After coding a Text Merge Behavior, create an action that allows users to create a Text Merge with the new behavior. This can be done by creating a Folder behavior that adds an action to the Folder to create a Text Merge with the new behavior. Below is a snippet from a Folder behavior class that shows how to add an action for creating a Text Merge with the new behavior type.
    public override BaseActionType[] GetFolderActions(Folder folder, BaseActionType[] proposedActions, EntityActionType[] types)
    {
       List<BaseActionType> actions = new List<BaseActionType>((proposedActions ?? new BaseActionType[0]));
    
       actions.Add(new CreateTextMergeAction("Create Sample TextMerge", null, null, "Create Sample TextMerge", null, typeof(CustomTextMergeBehavior).FullName));
    
       return actions.ToArray();
    }

Was this article helpful?