Code Fix: InOut Parameters not returned correctly for a K2 connect custom method
Introduction
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
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