Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

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
Kilo 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.

If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.