Description
The [error] variable does not persist in an [onAfter] script in a transform map.
Steps to Reproduce
1) create a data source into [sys_user] table with the following sample csv file as attachment:
email,first name,last name,user_name
abel.tuter@example.com,Abel,Tuter1,abel.tuter
kevin.owens@example.com,Kevin,Owens1,abel.tuter
Note that the second user has the first user's user_name and this will cause a duplicated key error when inserting.
2) Create a new transform map:
a) coalesce on [email] so they are treated as two different records, map the [user_name] to [sys_user].[user_name]
b) create an new [onAfter] script with the following script:
log.info('# log.info - OnAfter: Email: '+ source.u_email + ', error: ' + error)
3) Run the import and transform.
4) Expect a duplicated key error.
Expected Results: error variable is printed as [true]
Actual Results: error variable is printed as [false], the [error] value does not persist.
Workaround
This is expected behaviour. The [error] variable is not set to true while running the transformation in case of an error. It is available in a script to be able to stop the transformation.
Ref.:
Transformation script variables
Related Problem: PRB633362