Text Merge Behavior
  • Updated on 09 Dec 2013
  • 2 minutes to read
  • Print
  • Dark
    Light

Text Merge Behavior

  • Print
  • Dark
    Light

Similar to Flow Behavior and Folder Behavior , Text Merges can be given a 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.
To create a Text Merge behavior, create a public class that inherits from DefaultTextMergeBehavior . This will give you three overrideable methods which you can use to control the behavior of your Text Merge . These methods are:

  • public override void OnCreate(AbstractTextMerge merge) -- use this method to set default input data for your text merge. 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 your text merge.
 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)) };
}

When a text merge with this override is created, it will have a piece of input data which shows up in the designer. (Note: use your new behavior setting, in this case "Text Behavior," when opening then Text Merge) :

2017-02-10_115033.png

  • public override bool ShowInputs() -- use this method to hide the inputs from a designer user. Default behavior for this method is true (inputs are shown to user). Below is an example snippet showing how to hide the input data from the designer user.
 public override bool ShowInputs()
{
   return false;
}

When a text merge with this override is created, it will show up in the designer with the input data hidden as shown below.
2017-02-10_095608.png

If we had not overridden this method, the input data section would appear to the designer user as shown below.
2017-02-10_095032.png

  • public override BaseActionType[] GetAdditionalActions(ElementRegistration elementRegistration, TextMerge textMerge) -- use this method to add additional actions to the actions menu of your 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.
 public override BaseActionType[] GetAdditionalActions(ElementRegistration elementRegistration, TextMerge textMerge)
{
    List<baseactiontype> actions = new List<baseactiontype>();

    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();
}</baseactiontype></baseactiontype>

When a text merge with this override is created, it will show up in the designer with the additional action displayed as shown below.

2013-10-18_1418-300x166.png

After coding a Text Merge Behavior, you will need to create an action that allows users to create a Text Merge with your new behavior. To do this, we will create a folder behavior which adds an action to the folder to create a Text Merge with your new behavior. Below is a snippet from a folder behavior class which shows how to add an action for creating a Text Merge with your 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(SampleTextMergeBehavior).FullName));

    return actions.ToArray();
} </baseactiontype></baseactiontype>

A folder with this behavior will display an action called Create Sample TextMerge as shown below.

2013-10-18_1448-300x166.png

Was this article helpful?