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 = () => {
162162 await this . checkDuplication ( companyFields , companyIds ) ;
163163
164164 let scopeBrandIds : string [ ] = [ ] ;
165+ let customFieldsData = { } ;
165166 let tagIds : string [ ] = [ ] ;
166167 let names : string [ ] = [ ] ;
167168 let emails : string [ ] = [ ] ;
@@ -180,6 +181,9 @@ export const loadClass = () => {
180181 // Merging scopeBrandIds
181182 scopeBrandIds = [ ...scopeBrandIds , ...( companyObj . scopeBrandIds || [ ] ) ] ;
182183
184+ // merge custom fields data
185+ customFieldsData = { ...customFieldsData , ...( companyObj . customFieldsData || { } ) } ;
186+
183187 // Merging company's tag into 1 array
184188 tagIds = tagIds . concat ( companyTags ) ;
185189
@@ -208,6 +212,7 @@ export const loadClass = () => {
208212 const company = await Companies . createCompany ( {
209213 ...companyFields ,
210214 scopeBrandIds,
215+ customFieldsData,
211216 tagIds,
212217 mergedIds : companyIds ,
213218 names,
Original file line number Diff line number Diff line change @@ -261,6 +261,7 @@ export const loadClass = () => {
261261
262262 let scopeBrandIds : string [ ] = [ ] ;
263263 let tagIds : string [ ] = [ ] ;
264+ let customFieldsData = { } ;
264265
265266 let emails : string [ ] = [ ] ;
266267 let phones : string [ ] = [ ] ;
@@ -273,14 +274,16 @@ export const loadClass = () => {
273274 phones . push ( customerFields . primaryPhone ) ;
274275 }
275276
276- // Merging customer tags and companies
277277 for ( const customerId of customerIds ) {
278278 const customerObj = await Customers . findOne ( { _id : customerId } ) ;
279279
280280 if ( customerObj ) {
281281 // get last customer's integrationId
282282 customerFields . integrationId = customerObj . integrationId ;
283283
284+ // merge custom fields data
285+ customFieldsData = { ...customFieldsData , ...( customerObj . customFieldsData || { } ) } ;
286+
284287 // Merging scopeBrandIds
285288 scopeBrandIds = [ ...scopeBrandIds , ...( customerObj . scopeBrandIds || [ ] ) ] ;
286289
@@ -309,6 +312,7 @@ export const loadClass = () => {
309312 const customer = await this . createCustomer ( {
310313 ...customerFields ,
311314 scopeBrandIds,
315+ customFieldsData,
312316 tagIds,
313317 mergedIds : customerIds ,
314318 emails,
You can’t perform that action at this time.
0 commit comments