From c8765b4cf179dae303c9950431f8e6551165974b Mon Sep 17 00:00:00 2001 From: melton-jason Date: Mon, 24 Jun 2024 15:03:57 -0500 Subject: [PATCH] Determine domainfilter when fetching Field Picklist Items Fixes #4989 --- .../frontend/js_src/lib/components/PickLists/fetch.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/PickLists/fetch.ts b/specifyweb/frontend/js_src/lib/components/PickLists/fetch.ts index daabeb9ae74..e04f96cd3c5 100644 --- a/specifyweb/frontend/js_src/lib/components/PickLists/fetch.ts +++ b/specifyweb/frontend/js_src/lib/components/PickLists/fetch.ts @@ -14,7 +14,7 @@ import { deserializeResource, serializeResource, } from '../DataModel/serializers'; -import { strictGetTable } from '../DataModel/tables'; +import { genericTables, strictGetTable } from '../DataModel/tables'; import type { PickList, PickListItem, Tables } from '../DataModel/types'; import { softFail } from '../Errors/Crash'; import { format } from '../Formatters/formatters'; @@ -154,11 +154,17 @@ async function fetchFromField( pickList.get('fieldName') ?? undefined, 'Unable to fetch pick list items as pick list field is not set' ); + + const canBeScoped = + genericTables[tableName as keyof Tables]?.getScopingRelationship() !== + undefined || + !f.includes(Object.keys(schema.domainLevelIds), toLowerCase(tableName)); + return fetchRows(tableName as keyof Tables, { limit, fields: { [fieldName]: ['string', 'number', 'boolean', 'null'] }, distinct: true, - domainFilter: true, + domainFilter: canBeScoped, }).then((rows) => rows .map((row) => row[fieldName] ?? '')