platform/plugins/lead-resources/src/utils.ts
Alex 4f8b4706e9
Add objectTitle mixin (#2144)
Signed-off-by: Dvinyanin Alexandr <dvinyanin.alexandr@gmail.com>
2022-06-26 00:32:31 +07:00

10 lines
405 B
TypeScript

import { Doc, Ref, TxOperations } from '@anticrm/core'
import { Lead } from '@anticrm/lead'
import lead from './plugin'
export async function getLeadTitle (client: TxOperations, ref: Ref<Doc>): Promise<string> {
const object = await client.findOne(lead.class.Lead, { _id: ref as Ref<Lead> })
if (object === undefined) throw new Error(`Lead not found, _id: ${ref}`)
return `LEAD-${object.number}`
}