Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
The [error] variable does not persist in an [onAfter] script in a transform map - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • The [error] variable does not persist in an [onAfter] script in a transform map
KB0676966

The [error] variable does not persist in an [onAfter] script in a transform map


2022 Views Last updated : Jan 28, 2024 public Copy Permalink
KB Summary by Now Assist

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

Field map script variables

 


Related Problem: PRB633362

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.