Skip Navigation
Can the exit function be used in a custom process?
Answer ID 6706   |   Last Review Date 07/22/2019

Why am I getting an error when I use exit() in a custom process?


Process Designer, Custom Process Model (CPM), Service Process Model (SPM)
November 2012 and newer releases


In the past, external events permitted the use of the function exit to stop processing.

This statement will produce an error in the live testing, and should also produce an error when the test button is pressed.

Example of info_log entry: 

File: dquery/spmerrorshandler.cpp
Line: 249
In Fcn: SPMErrorsHandler::insert_stats
Description: Object Event Handler incident_create failed while processing an Incident object with ID 1261679:
   Script exited (perhaps die(0)?)

Best practice is to convert an exit to a return.

// if (!$org_id || $org_id === 0) exit;   // corrected by using return;
            if (!$org_id || $org_id === 0) return;    // This works