SDK: Text Merge Behavior
- 19 Aug 2021
- 2 Minutes to read
- Print
- DarkLight
This documentation version is deprecated, please click here for the latest version.
SDK: Text Merge Behavior
- Updated on 19 Aug 2021
- 2 Minutes to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
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.
- 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.
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 that shows up in the Designer (use the new behavior setting, Text Behavior when opening the Text Merge). - 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.
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.If the method had not been overridden, the input data section would appear to the Designer user as shown below.
- 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.
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(); }
When a text merge with this override is created, it will show up in the designer with the additional action displayed as shown below.
- 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.
- After coding a Text Merge Behavior, create an action that allows users to create a Text Merge with the new behavior. Create 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(); }
A Folder with this behavior will display an action called Create Sample TextMerge as shown below.
Was this article helpful?