What does the compatibility switch do?
For more details, read the migration 2.5->3.0 doc.
How to check for the existence of fields in rows (with compatibility on)?
The following snippet (using compatibility switched on) will let you check this. But keep in mind that you can not mix rows in PDI, all rows flowing over a single hop have to have the same number of fields, which have to be of the same name and type.
The same snippet without compatibility switched on:
How to add a new field in a row
Note up front that the order in which fields are added to a row is important. Always add fields in the same order to keep the structure of the row coherent.
Now to add a field:
How to modify values (with compatibility off)
How to modify values (with compatibility on)
When compatibility is switched on, use setValue on the input field as follows (assuming field1 is a field in the input row):
setValue() takes all possible types that can be used in PDI (also String, Dates, ...).
You can use the following construction (to get something like nvl(a, '0')) with the compatibility switch on:
and you can also use:
which would replace the value of fieldName with the value of '1' if fieldName is null.
Example of how to split fields
In a field I have merchant code containing numbers and characters, ex. "12345McDonalds". I want to split it but the field doesn't have a consistent layout and I want to split the first part which is numeric from the second part.
The Alert() is just to show the fields of course. After the outer for loop you could add code and name in new separate fields e.g.