cancel
Showing results for 
Search instead for 
Did you mean: 

CPI - if function returns multiple values

Jwan
Explorer
0 Kudos
121

the if function is returning always the true value and the false value together in the same context, which makes my target structure take the false value (as being the first value).

I could manage the issue with the following udf-script and mapping:

def void conditionalMappingSingle(String[] conditions, String[] trueValues, String[] falseValues, Output output, MappingContext context) {
    // Loop through the conditions and find the first true value
    for (int i = 0; i < conditions.length; i++) {
        if ("true".equalsIgnoreCase(conditions[i])) {
            output.addValue(trueValues[i]); // Add the corresponding true value to the output
            return; // Exit after finding the first true value
        }
    }
    // If no true value is found, add the first false value to the output
    if (falseValues.length > 0) {
        output.addValue(falseValues[0]); // Default to the first false value
    }
}

Using if (standard function)

Jwan_0-1737563225610.png

 

 

using user-defined function:

Jwan_1-1737563225602.png

 

Isn't there a way to solve it with the standard mapping functions?

Accepted Solutions (0)

Answers (0)