getServiceFactory()->create('LeadCapture')->confirmOptIn($id); if ($data->status === 'success') { $action = 'optInConfirmationSuccess'; } else if ($data->status === 'expired') { $action = 'optInConfirmationExpired'; } else { throw new Error(); } $runScript = " Espo.require('controllers/lead-capture-opt-in-confirmation', function (Controller) { var controller = new Controller(app.baseController.params, app.getControllerInjection()); controller.masterView = app.masterView; controller.doAction('".$action."', ".json_encode($data)."); }); "; $this->getClientManager()->display($runScript); } }