While researching for my last post, Thinking outside the box (or not): How to create “Global C# function” to be reused inside a map?, in BizTalk360 blog, I encountered several errors while playing around with maps in order to find an approach that would allow me to create the concept of Global Function. And some of these errors were:
“Inline Script Error: must declare a body because it is not marked abstract, extern, or partial”
“Inline Script Error: ; expected”
or
“Inline Script Error: Type ‘BizTalkMapper.FunctoidInlineScripts’ already defines a member called ‘FunctionName’ with the same parameter types”
Causes
The cause of this problem is that you do not correctly declare the body of the Inline C# Function.
Or, if you are trying to reuse an existing Inline C# Function you are doing it properly.
To reuse Inline C# Functions these are the rules that you need to follow:
- If all of the Scripting Functoids are in the same grid page: In the first Scripting Functoid, linked from the source to the destination, we will have to specify the body function and in the following functoids, we only need the function declaration (nobody).
- If the Scripting Functoids are in different grid pages: The Scripting Functoid that specifies the body function needs to be on the leftmost grid page and the remaining Scripting Functoids (with the function body declared) on the other grid pages to the right. In other words, counting the grid pages from left to right, if the Scripting Functoid that specifies the body function is on the second grid page, the remaining functoids with the function body declared, cannot be placed on the first grid page, they can only be placed on the second grid page (including the second).
Solution
The solution to solve this issue you have two options, you need to follow the rules described above (BizTalk Mapper tips and tricks: How to reuse Scripting Functoids with Inline C# inside the same map) or you need to implement the concept of global C# Function described in my post: Thinking outside the box (or not): How to create “Global C# function” to be reused inside a map?, in resume:
- Add a Grid page to your map and rename it to “GlobalFunctions”
- Set this grid as the first grid page of your map (important step)
- Drag-and-Drop a Scripting Functoid to the “GlobalFunctions” grid page and place the C# code
- Do not link any inputs and don’t map (link) this Scripting Functoids to any element in the destination Schema.
- Double click the earlier Scripting Functoids added to the “GlobalFunctions” grid page and set the expected input values as empty constant values, that by default doesn’t exist
- Now you can use these functions in other grid pages using only the function declaration