This repository was archived by the owner on Nov 21, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,7 @@ export const loadClass = () => {
162
162
await this . checkDuplication ( companyFields , companyIds ) ;
163
163
164
164
let scopeBrandIds : string [ ] = [ ] ;
165
+ let customFieldsData = { } ;
165
166
let tagIds : string [ ] = [ ] ;
166
167
let names : string [ ] = [ ] ;
167
168
let emails : string [ ] = [ ] ;
@@ -180,6 +181,9 @@ export const loadClass = () => {
180
181
// Merging scopeBrandIds
181
182
scopeBrandIds = [ ...scopeBrandIds , ...( companyObj . scopeBrandIds || [ ] ) ] ;
182
183
184
+ // merge custom fields data
185
+ customFieldsData = { ...customFieldsData , ...( companyObj . customFieldsData || { } ) } ;
186
+
183
187
// Merging company's tag into 1 array
184
188
tagIds = tagIds . concat ( companyTags ) ;
185
189
@@ -208,6 +212,7 @@ export const loadClass = () => {
208
212
const company = await Companies . createCompany ( {
209
213
...companyFields ,
210
214
scopeBrandIds,
215
+ customFieldsData,
211
216
tagIds,
212
217
mergedIds : companyIds ,
213
218
names,
Original file line number Diff line number Diff line change @@ -261,6 +261,7 @@ export const loadClass = () => {
261
261
262
262
let scopeBrandIds : string [ ] = [ ] ;
263
263
let tagIds : string [ ] = [ ] ;
264
+ let customFieldsData = { } ;
264
265
265
266
let emails : string [ ] = [ ] ;
266
267
let phones : string [ ] = [ ] ;
@@ -273,14 +274,16 @@ export const loadClass = () => {
273
274
phones . push ( customerFields . primaryPhone ) ;
274
275
}
275
276
276
- // Merging customer tags and companies
277
277
for ( const customerId of customerIds ) {
278
278
const customerObj = await Customers . findOne ( { _id : customerId } ) ;
279
279
280
280
if ( customerObj ) {
281
281
// get last customer's integrationId
282
282
customerFields . integrationId = customerObj . integrationId ;
283
283
284
+ // merge custom fields data
285
+ customFieldsData = { ...customFieldsData , ...( customerObj . customFieldsData || { } ) } ;
286
+
284
287
// Merging scopeBrandIds
285
288
scopeBrandIds = [ ...scopeBrandIds , ...( customerObj . scopeBrandIds || [ ] ) ] ;
286
289
@@ -309,6 +312,7 @@ export const loadClass = () => {
309
312
const customer = await this . createCustomer ( {
310
313
...customerFields ,
311
314
scopeBrandIds,
315
+ customFieldsData,
312
316
tagIds,
313
317
mergedIds : customerIds ,
314
318
emails,
You can’t perform that action at this time.
0 commit comments