1

When writing the following when/otherwise condition, the value of "derived_company_id" as null. What is it that the code is missing?

Code:

%dw 1.0
%output application/java
---
{
  src_account_type:  "external",    
  tgt_company_id :    "Mary",
  src_company_id :    "Sneha",
  derived_company_id: payload.tgt_company_id 
                        when payload.src_account_type == "external"
                        otherwise payload.src_company_id
}

Console

LoggerMessageProcessor: derived_company_id ::{src_account_type=external, tgt_company_id=Mary, src_company_id=Sneha, derived_company_id=null}
jerney
  • 2,187
  • 1
  • 19
  • 31
  • Hi Mary, what are the values of `payload.tgt_company_id` and `payload.src_company_id` at the time of the transformation? Also, in this mapping, what were you expecting the result to be? – jerney Oct 08 '18 at 16:24

1 Answers1

0

Because you didn't provide the input for the transformation I will take an educated guess: either payload.src_account_type == "external" is true and payload.tgt_company_id is null or is not present in the input payload, or payload.src_account_type != "external" and payload.src_company_id is null or not present in the input payload. I tested this with a JSON input. If a key is not present it evaluates to null.

aled
  • 21,330
  • 3
  • 27
  • 34