Commit 002f116 authored Mar 11, 2024 · 1 / 2 · Verified
1 parent 3c637e4 commit 002f116 Copy full SHA for 002f116
File tree 2 files changed +26
-15
lines changed
packages/backend/services/crm
2 files changed +26
-15
lines changed Original file line number Diff line number Diff line change @@ -832,19 +832,26 @@ const contactService = new ContactService(
832
832
authorization : `Zoho-oauthtoken ${ thirdPartyToken } ` ,
833
833
} ,
834
834
} ) ;
835
- contacts = contacts . data . data ;
836
- contacts = await Promise . all (
837
- contacts ?. map (
838
- async ( l : any ) =>
839
- await unifyObject < any , UnifiedContact > ( {
840
- obj : l ,
841
- tpId : thirdPartyId ,
842
- objType,
843
- tenantSchemaMappingId : connection . schema_mapping_id ,
844
- accountFieldMappingConfig : account . accountFieldMappingConfig ,
845
- } )
846
- )
847
- ) ;
835
+ const isValidContactData =
836
+ contacts . data && contacts . data . data !== undefined && Array . isArray ( contacts . data . data ) ;
837
+ if ( isValidContactData ) {
838
+ contacts = contacts ?. data ?. data ;
839
+
840
+ contacts = await Promise . all (
841
+ contacts ?. map (
842
+ async ( l : any ) =>
843
+ await unifyObject < any , UnifiedContact > ( {
844
+ obj : l ,
845
+ tpId : thirdPartyId ,
846
+ objType,
847
+ tenantSchemaMappingId : connection . schema_mapping_id ,
848
+ accountFieldMappingConfig : account . accountFieldMappingConfig ,
849
+ } )
850
+ )
851
+ ) ;
852
+ } else {
853
+ contacts = [ ] ;
854
+ }
848
855
res . send ( { status : 'ok' , results : contacts } ) ;
849
856
break ;
850
857
}
Original file line number Diff line number Diff line change @@ -469,15 +469,19 @@ const eventService = new EventService(
469
469
break ;
470
470
}
471
471
case TP_ID . zohocrm : {
472
- await axios ( {
472
+ const eventCreated : any = await axios ( {
473
473
method : 'post' ,
474
474
url : `https://www.zohoapis.com/crm/v3/Events` ,
475
475
headers : {
476
476
authorization : `Zoho-oauthtoken ${ thirdPartyToken } ` ,
477
477
} ,
478
478
data : JSON . stringify ( event ) ,
479
479
} ) ;
480
- res . send ( { status : 'ok' , message : 'Zoho event created' , result : event } ) ;
480
+ res . send ( {
481
+ status : 'ok' ,
482
+ message : 'Zoho event created' ,
483
+ result : { ...event , details : eventCreated . data . data [ 0 ] . details } ,
484
+ } ) ;
481
485
break ;
482
486
}
483
487
case TP_ID . sfdc : {
You can’t perform that action at this time.
0 commit comments