How can I trigger an error in a transform map script in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2025 09:54 PM
How can I trigger an error in a transform map script in ServiceNow so that the record goes to the 'onReject' stage instead of calling 'onForeignInsert' or 'onChoiceCreate'? I want to validate a field (like status = 'Pending') and prevent further processing if the value is invalid ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2025 02:22 PM - edited ‎09-25-2025 02:23 PM
Hi @PrathameshD3158
To trigger a record rejection in a ServiceNow transform map, you must use an onBefore script and set the ignore variable to true. You can also provide a detailed error message by setting the error_message variable.
This stops the transformation for the current row, preventing subsequent scripts like onForeignInsert or onChoiceCreate from executing.
