This object has a set of header levels at the root node, referred to as “Invoice-header.” It also has a collection of “Invoice-lines,” which represent individual line items on the invoice. To illustrate this, consider a scenario where you have an XML payload that represents an invoice. when ?,ġ. Transforming XML payloads can be tricky if you need to handle scenarios where you are mapping an XML collection, which is potentially empty. Going back to our airline flight scheduling scenario, below is an example in which the airline needs to generate an output field called “OperEstDepTime,” but only when a particular input field is not null.įlightNumber: , On the other hand, if the field is null, then it would return false. (FlightStatus: "RETURN_TO_GATE") when = "RTR", Step 2: Checking fields for nullsġ. In DataWeave, when a field in the input payload has a value and you append a question mark (“?”) at the end of the field, it will return true. (FlightStatus: "OFFGROUND") when = "DEP" Here, we are setting the value of a field called “FlightState” to 6 possible values, which are based on 11 possible values that are sent in a field called “”: (FlightStatus: "SCHEDULED") when = "SKD" Below is a more complex case in which there are many mappings between input and output values. Otherwise, we default the value to something else when the input doesn’t match the condition: (FlightType: "DIVERT" when = "DIV"Ģ. The following is a simple if/else scenario, where we check the input for a specific value and set the output accordingly. To illustrate this, we will look at two DataWeave snippets for an airline flight scheduling scenario. In order to implement conditional mappings in DataWeave with if/else logic, you will provide the when/or/otherwise syntax.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |