diff --git a/backend/src/services/organizationService.ts b/backend/src/services/organizationService.ts index 58bcfeb07d..cb6cb3cb2f 100644 --- a/backend/src/services/organizationService.ts +++ b/backend/src/services/organizationService.ts @@ -446,6 +446,11 @@ export default class OrganizationService extends LoggerBase { if (existing) { await OrganizationRepository.checkIdentities(data, this.options, existing.id) + // Set displayName if it doesn't exist + if (!existing.displayName) { + data.displayName = cache.name + } + record = await OrganizationRepository.update( existing.id, { ...data, ...cache }, diff --git a/backend/src/services/premium/enrichment/organizationEnrichmentService.ts b/backend/src/services/premium/enrichment/organizationEnrichmentService.ts index 607f4449f2..f2392a6fd7 100644 --- a/backend/src/services/premium/enrichment/organizationEnrichmentService.ts +++ b/backend/src/services/premium/enrichment/organizationEnrichmentService.ts @@ -373,6 +373,12 @@ export default class OrganizationEnrichmentService extends LoggerBase { } } + // Set displayName using the first identity or fallback to website + if (!data.displayName) { + const identity = data.identities[0] + data.displayName = identity ? identity.name : data.website + } + return lodash.pick( { ...data, lastEnrichedAt: new Date() }, this.selectFieldsForEnrichment(instance), diff --git a/services/libs/types/src/organizations.ts b/services/libs/types/src/organizations.ts index e4049d85de..6ec71b1110 100644 --- a/services/libs/types/src/organizations.ts +++ b/services/libs/types/src/organizations.ts @@ -3,6 +3,7 @@ import { OrganizationSource } from './enums/organizations' export interface IOrganization { id?: string + displayName?: string url?: string description?: string emails?: string[]