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.
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);
outString = "out1~out2#";
outString += Convert.ToString(dr["out1"]) + "~" + Convert.ToString(dr["out2"]);
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('#');
values = fieldsAndValues.Split('#');
fieldsArray = fields.Split('~');
valueArray = values.Split('~');
for (int i = 0; i < fieldsArray.Length; i++)
if (fieldsArray[i] == columnName)
result = valueArray[i];
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:
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:
Map the output of the custom functoid to the respective fields in the destination schema. Find the figure below:
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.