Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ProcessMaker/ImportExport/Exporters/ScriptExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use ProcessMaker\ImportExport\DependentType;
use ProcessMaker\Models\EnvironmentVariable;
use ProcessMaker\Models\ScriptCategory;
use ProcessMaker\Models\User;

class ScriptExporter extends ExporterBase
{
Expand Down Expand Up @@ -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) {
Expand Down