diff --git a/ProcessMaker/ImportExport/Exporters/ScriptExporter.php b/ProcessMaker/ImportExport/Exporters/ScriptExporter.php index 84a87421cd..e0113e8424 100644 --- a/ProcessMaker/ImportExport/Exporters/ScriptExporter.php +++ b/ProcessMaker/ImportExport/Exporters/ScriptExporter.php @@ -5,6 +5,7 @@ use ProcessMaker\ImportExport\DependentType; use ProcessMaker\Models\EnvironmentVariable; use ProcessMaker\Models\ScriptCategory; +use ProcessMaker\Models\User; class ScriptExporter extends ExporterBase { @@ -35,7 +36,9 @@ public function import() : bool foreach ($this->getDependents('user', true) as $dependent) { $scriptUser = $dependent->model; - $this->model->run_as_user_id = $scriptUser->id; + // Assign the user ID to run the script + // If the user is not set in the dependent modal, default to the admin user + $this->model->run_as_user_id = $scriptUser?->id ?? User::where('is_administrator', true)->first()->id; } foreach ($this->getDependents('executor', true) as $dependent) {