From 53d323a59421336bf574d32d43630d851cfb2b32 Mon Sep 17 00:00:00 2001 From: Kat Date: Thu, 21 Dec 2023 14:30:47 +0000 Subject: [PATCH] Only get org if id is given --- app/controllers/form_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index 9fb0fe243..2f6ce6483 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -103,7 +103,7 @@ private end if question.id == "owning_organisation_id" - owning_organisation = Organisation.find(result["owning_organisation_id"]) + owning_organisation = result["owning_organisation_id"].present? ? Organisation.find(result["owning_organisation_id"]) : nil if current_user.support? && @log.managing_organisation.blank? && owning_organisation&.managing_agents&.empty? result["managing_organisation_id"] = owning_organisation.id elsif owning_organisation&.absorbing_organisation == current_user.organisation