From d45a1d31bfbc2b2918a93a207345ad1029a0d498 Mon Sep 17 00:00:00 2001 From: Saeid Hassanabadi Date: Tue, 27 Oct 2026 12:57:17 +0100 Subject: [PATCH 1/2] Return import rows as objects --- .../Servicenowimport/ProvidedHook/Director/ImportSource.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/Servicenowimport/ProvidedHook/Director/ImportSource.php b/library/Servicenowimport/ProvidedHook/Director/ImportSource.php index e072383..c838032 100644 --- a/library/Servicenowimport/ProvidedHook/Director/ImportSource.php +++ b/library/Servicenowimport/ProvidedHook/Director/ImportSource.php @@ -275,7 +275,10 @@ private function getRecordsFromTable(): array $result = $this->extractDisplayValues($data['result'] ?? []); - return $result; + // The Director expects every row to be an object (e.g. for property modifiers) + return array_map(function ($row) { + return (object) $row; + }, $result); } /* From c59b5f189d01797536788a44cd7c29610235871a Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Thu, 12 Nov 2026 09:35:46 +0100 Subject: [PATCH 2/2] [squash] --- .../ProvidedHook/Director/ImportSource.php | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/library/Servicenowimport/ProvidedHook/Director/ImportSource.php b/library/Servicenowimport/ProvidedHook/Director/ImportSource.php index c838032..f8c2be8 100644 --- a/library/Servicenowimport/ProvidedHook/Director/ImportSource.php +++ b/library/Servicenowimport/ProvidedHook/Director/ImportSource.php @@ -260,7 +260,7 @@ private function getRecordsFromTable(): array $auth ); - $result = $client->request( + $resp = $client->request( $endpoint, [ 'query' => [ @@ -271,31 +271,20 @@ private function getRecordsFromTable(): array ] ); - $data = Json::decode($result, true); + $data = Json::decode($resp); - $result = $this->extractDisplayValues($data['result'] ?? []); - - // The Director expects every row to be an object (e.g. for property modifiers) - return array_map(function ($row) { - return (object) $row; - }, $result); - } - - /* - * extractDisplayValues returns a copy of the given array but with - * the with display_value as the values instead of objects. - * We use sysparm_display_value the expand the ServiceNow objects. - * each object will have the actual value in the field display_value. - */ - protected function extractDisplayValues(array $array): array - { - return array_map(function ($value) { - if (!is_array($value)) { - return $value; + // We use sysparm_display_value the expand the ServiceNow objects. + // each object will have the actual value in the field display_value. + // Note, we need to return an array of stdclass objects. + foreach ($data->result as $row) { + foreach (get_object_vars($row) as $key => $value) { + if (is_object($value) && property_exists($value, 'display_value')) { + $row->$key = $value->display_value; + } } + } - return array_key_exists('display_value', $value) ? $value['display_value'] : $this->extractDisplayValues($value); - }, $array); + return $data->result; } protected static function addProxy(QuickForm $form)