All custom functoids must derive from the BaseFunctoid class. You must first override the constructor and make a set of calls that tell BizTalk Mapper about your custom functoid. Then you need to write the functoid logic.
Overriding the Constructor
You must perform a number of tasks in the class constructor override method to characterize your functoid. These tasks are in addition to any functoid-specific code your solution requires. The following table describes the primary tasks.
Task
Use these methods or properties
Comments
Assign a unique ID to the functoid
ID
Use a value greater than 6000 that has not been used. Values less than 6000 are reserved for use by internal functoids.
Indicate whether the functoid has side effects
HasSideEffects
Used by the mapper to optimize the XSLT code that is generated. This property is true by default.
Point to the resource assembly
SetupResourceAssembly
Include a resource file with your project. If building with Visual Studio, the resource assembly must be ProjectName.ResourceName.
Enable the custom functoid to appear in the BizTalk Mapper palette
SetName
SetTooltip
SetDescription
SetBitmap
Use a resource ID pointing to a string for the name, tooltip and description; use a 16x16-pixel bitmap.
Use the SetMinParams method to set the number of required parameters and the SetMaxParams method to set the number of optional parameters. Use the following guidelines to set these values:
- If you have no optional parameters, set min = max. - If you have some optional parameters, set max = (number of optional parameters - min number of parameters). - If you want to allow unlimited optional parameters, do not set max. - If you have a variable number of inputs, do not set min or max, and set HasVariableInputs = true.
Use values from Microsoft.BizTalk.BaseFunctoids.ConnectionType to tell BizTalk Mapper the types of objects that can receive output from your functoid. Use OR to specify multiple connection types.
Tell BizTalk Server which methods to invoke for your functoid
SetExternalFunctionName
SetExternalFunctionName2
SetExternalFunctionName3
For cumulative functoids, use SetExternalFunctionName to set the initialization function, SetExternalFunctionName2 to set the accumulation function, and SetExternalFunctionName3 to specify the function that returns the accumulated value. For noncumulative functoids use SetExternalFunctionName to set the functoid method.
Have BizTalk Server use inline code to invoke your functoid
AddScriptTypeSupport SetScriptBuffer
Call AddScriptTypeSupport with Microsoft.BizTalk.BaseFunctoids.ScriptType to enable inline code. Invoke SetScriptBuffer to pass in the code for the functoid. This code will be copied into the map.
Declare global variables for an inline functoid
SetScriptGlobalBuffer
Any declarations made will be visible to other inline scripts included in the map.
Indicate which helper functions your inline functoid requires
RequiredGlobalHelperFunctions
Use values from the InlineGlobalHelperFunction enumeration to specify which helper functions are required. Use OR to specify multiple helper functions.
Validate parameters passed to your functoid
IsDate
IsNumeric
These functions provide a true/false answer without throwing an exception.
Implementing Functoid Logic
To make the functoid useful you must implement one or more methods depending upon the functoid category. If the functoid is cumulative, then you need to supply three methods—one for initialization, one to do the accumulation, and one to return the accumulated value. If the functoid is not cumulative, then you need to supply one method that returns a value.
You also have to decide if the functoid implementation code should be copied inline into the map or kept within a compiled .NET assembly and used through a reference.
Consider using an inline functoid when:
It is okay for others to read and potentially modify your business logic.
Extended data types (EDTs) and base enumerations (enums) are data types that are created and managed in the development environment. Base enums represent a list of literals, while EDTs are reusable data types that have a specific definition. The Application Object Tree (AOT) in finance and operations apps contains many existing EDTs and base enums that can be extended for use in your project, or you can create new data types. This module will focus on creating new data types.