Code Fix: InOut Parameters not returned correctly for a K2 connect custom method
LEGACY/ARCHIVED CONTENT
This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.
Introduction
A K2 connect Service Object which includes a custom method, does not handle InOut Mappings correctly.
Error Scenario
| Note: The steps in this article describes one scenario under which this issue may occur. They are simplified and not all steps are shown or described. |
In this scenario, a service object is created implementing a custom method. The following parameters are implemented:
| Parameter | Description | Type | Direction |
| NameIn | Flat | String | In |
| NameOut_A | Flat | String | InOut |
| NameOut_B | Flat | String | InOut |
| NameOut_C | Flat | String | Out |

[Figure 1. Function Interface]
The parameter “NameIn” is the value that will be passed in; the following mappings have been created for return values:
- “NameOut_A” is mapped directly to “NameIn”
- “NameOut_B” is mapped to “NameIn” with a transformation
- “NameOut_C” is mapped directly to “NameIn“
The differences between the first and last is that “NameOut_A” is an INOUT and “NameOut_C” is just an OUT. The corresponding screenshot for the K2 data mapper, is displayed below:
[Figure 2. Data Mappings]
With this configuration in place, the Service Object can be published. To verify the error, use the SmartObject tester tool and set “NameIn” to “Mary”. The expected results are listed below, alongside the actual results:
| Expected | Actual | ||
| NameOut_A | "Mary" | NameOut_A | "" (empty) |
| NameOut_B | "Mary -- THIS IS A TEST" | NameOut_B | "" (empty) |
| NameOut_C | "Mary" | NameOut_C | "Mary" |

[Figure 3. SmartObject Tool]
Error Resolution
The InOut parameters are not returned in this instance because the K2 ServiceBroker was not returning 'flat' parameters correctly.
An update to the K2 ServiceBroker is required to rectify the issue. This Hotfix is contained within the latest K2 blackpearl 0807 Update. Install the update package to resolve the error.
The latest K2 blackpearl 0807 Update is available as an independent installation package which can be found here: https://portal.k2.com/downloads/bp/default.aspx
An update to the K2 ServiceBroker is required to rectify the issue. This Hotfix is contained within the latest K2 blackpearl 0807 Update. Install the update package to resolve the error.
The latest K2 blackpearl 0807 Update is available as an independent installation package which can be found here: https://portal.k2.com/downloads/bp/default.aspx
