Skip to content

Commit b8fe6d7

Browse files
committed
fix: template create record with referecegst
1 parent 4339f3e commit b8fe6d7

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

packages/table/src/modules/records/services/methods/create-tables-records.method.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ export async function createTablesRecordsMethod(
2121
if (value.isNone()) {
2222
continue
2323
}
24-
const spec = new ReferenceEqual(value.unwrap() as ReferenceFieldValue, field.id)
25-
specs.push(spec)
24+
const referecneValue = value.unwrap() as ReferenceFieldValue
25+
if (referecneValue.value?.length) {
26+
const spec = new ReferenceEqual(value.unwrap() as ReferenceFieldValue, field.id)
27+
specs.push(spec)
28+
}
2629
}
2730

28-
const spec = and(...specs) as Option<RecordComositeSpecification>
29-
await this.repo.updateOneById(table, record, spec)
31+
if (specs.length) {
32+
const spec = and(...specs) as Option<RecordComositeSpecification>
33+
await this.repo.updateOneById(table, record, spec)
34+
}
3035
}
3136
}
3237
}

packages/template/src/templates/crm.base.json

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,30 @@
5454
"id": "company",
5555
"type": "reference",
5656
"option": {
57+
"createSymmetricField": true,
5758
"foreignTable": {
5859
"tableName": "Companies"
5960
}
6061
}
6162
},
63+
"Company Name": {
64+
"id": "companyName",
65+
"type": "rollup",
66+
"option": {
67+
"referenceFieldId": "company",
68+
"rollupFieldId": "name",
69+
"fn": "lookup"
70+
}
71+
},
72+
"Company Industry": {
73+
"id": "companyIndustry",
74+
"type": "rollup",
75+
"option": {
76+
"referenceFieldId": "company",
77+
"rollupFieldId": "industry",
78+
"fn": "lookup"
79+
}
80+
},
6281
"Deals": {
6382
"id": "deals",
6483
"type": "reference",
@@ -1074,16 +1093,6 @@
10741093
"Website": {
10751094
"id": "website",
10761095
"type": "url"
1077-
},
1078-
"Contacts": {
1079-
"id": "contacts",
1080-
"type": "reference",
1081-
"option": {
1082-
"foreignTable": {
1083-
"tableName": "Contacts"
1084-
},
1085-
"createSymmetricField": true
1086-
}
10871096
}
10881097
},
10891098
"records": [

0 commit comments

Comments
 (0)