How can I trigger an error in a transform map script in ServiceNow

Prathmeshda
Tera Guru

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 ?

1 REPLY 1

Rafael Batistot
Mega Patron

Hi @Prathmeshda 

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.