Click here to Skip to main content
13,290,729 members (67,110 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 10 Oct 2009

Functoid with more than one output value

, 10 Oct 2009
Rate this:
Please Sign up or sign in to vote.
Functoid with more than one output value


When we were working on one of the BizTalk projects, we were facing difficulties because of not having a built in functoid that will have more than one return value. To overcome this issue, we came up with the following solution.

Problem Statement

Retrieve two field’s values from the database based on the input values. And the retrieved two field’s values should be assigned to the three different fields in the destination schema of the map. And all these activities should happen in the map.


1. Create a Method for Retrieving the Value from the Database

Given below is the sample code:

public static string GetSuppRecordForAP(string input1, string input2, string input3)
Database db = null;
IDataReader dr = null;
DbCommand cmd = null;
string suppQuery = string.Empty;
string SPSTID = string.Empty;
string outString = string.Empty;
String query = String.Empty;
Int32 orgId = 0;
db = DatabaseHelper.Instance.CreateDatabase("database1");
cmd = db.GetSqlStringCommand
("select out1,out2 from table where field1='" + input1 +
"' AND field2='" + input2 + "' AND field3='" + input3 + "'");
cmd.CommandType = CommandType.Text;
dr = db.ExecuteReader(cmd);
if (dr.Read())
outString = "out1~out2#";
outString += Convert.ToString(dr["out1"]) + "~" + Convert.ToString(dr["out2"]);
return outString;
if (dr != null)

The output of the above method will be like out1~out2#value1~value2.

Note: Make sure that the special characters used will not be part of the data.

2. Create a Custom Functoid that will Accept 2 Input String Parameters

The custom functoid should accept 2 input parameters, and the first parameter is for accepting the string in the format out1~out2#value1~value2 and the second parameter is for receiving the name of the field whose value needs to be retrieved.

3. Sample Code for Main Function that will Help to Retrieve the Value in the Custom Functoid

public string ColumnValueExtractor(string fieldsAndValues, string columnName)
ResourceManager resmgr = new ResourceManager
string fields = string.Empty;
string values = string.Empty;
string[] fieldsArray = null;
string[] valueArray = null;
string result = string.Empty;
fields = fieldsAndValues.Split('#')[0];
values = fieldsAndValues.Split('#')[1];
fieldsArray = fields.Split('~');
valueArray = values.Split('~');
for (int i = 0; i < fieldsArray.Length; i++)
if (fieldsArray[i] == columnName)
result = valueArray[i];
return result;
return result;


Use this link for help with creating a custom functoid.

4. Use the Custom Functoid in the Map

You can find more details below:

Use a scripting functoid that will call the .NET method that is created in step 1. The figure is as shown below:

Figure 1.

Use the custom functoid that is created in step 2 & 3 and give the output of the above scripting functoid as the first parameter and the name of the field whose value needs to be retrieved as the second parameter. Find the figure as follows:

Figure 2.

Map the output of the custom functoid to the respective fields in the destination schema. Find the figure below:

Figure 3.

Note: The blue colored functoids are the new custom functoids created in steps 2 & 3. And based on your requirements, customize the methods used in the .NET component to retrieve the value and the customer functoid method.


  • 10th October, 2009: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer accenture
India India
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
pintyo11-Oct-09 12:39
memberpintyo11-Oct-09 12:39 
GeneralMy vote of 1 Pin
ron99klein10-Oct-09 23:39
memberron99klein10-Oct-09 23:39 
That's a single output value. The fact that it's a serialized data structure doesn't make it different than a simple string.
QuestionWhy? Pin
Saurabh.Garg10-Oct-09 16:33
memberSaurabh.Garg10-Oct-09 16:33 
AnswerRe: Why? Pin
gaurav_verma_mca10-Oct-09 21:54
membergaurav_verma_mca10-Oct-09 21:54 
GeneralRe: Why? Pin
Saurabh.Garg11-Oct-09 0:37
memberSaurabh.Garg11-Oct-09 0:37 
GeneralRe: Why? Pin
gaurav_verma_mca11-Oct-09 0:50
membergaurav_verma_mca11-Oct-09 0:50 
GeneralRe: Why? Pin
Saurabh.Garg11-Oct-09 0:55
memberSaurabh.Garg11-Oct-09 0:55 
GeneralRe: Why? Pin
gaurav_verma_mca11-Oct-09 0:58
membergaurav_verma_mca11-Oct-09 0:58 
GeneralRe: Why? Pin
Saurabh.Garg11-Oct-09 1:00
memberSaurabh.Garg11-Oct-09 1:00 
GeneralRe: Why? Pin
gaurav_verma_mca11-Oct-09 1:02
membergaurav_verma_mca11-Oct-09 1:02 
GeneralRe: Why? Pin
Saurabh.Garg11-Oct-09 1:09
memberSaurabh.Garg11-Oct-09 1:09 
GeneralRe: Why? Pin
gaurav_verma_mca11-Oct-09 1:17
membergaurav_verma_mca11-Oct-09 1:17 
GeneralRe: Why? Pin
Sarmak.M.C11-Oct-09 5:37
memberSarmak.M.C11-Oct-09 5:37 
GeneralGood work Pin
gaurav_verma_mca10-Oct-09 6:29
membergaurav_verma_mca10-Oct-09 6:29 
GeneralRe: Good work Pin
Sarmak.M.C10-Oct-09 8:07
memberSarmak.M.C10-Oct-09 8:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 10 Oct 2009
Article Copyright 2009 by Sarmak.M.C
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid