Skip to content

Commit 6d2f35b

Browse files
authored
Merge pull request #44 from umbraco/v10/feature/crm-updatecontact
Allow contact update flag for CRM integrations: ActiveCampaign & HubSpot
2 parents c0e7f2c + 2df0484 commit 6d2f35b

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

src/Umbraco.Forms.Integrations.Crm.ActiveCampaign/ActiveCampaignContactsWorkflow.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ public override WorkflowExecutionStatus Execute(WorkflowExecutionContext context
6767
// Check if contact exists.
6868
var contacts = _contactService.Get(email).ConfigureAwait(false).GetAwaiter().GetResult();
6969

70+
if(contacts.Contacts.Count > 0 && !_settings.AllowContactUpdate)
71+
{
72+
_logger.LogInformation("Contact already exists in ActiveCampaign and workflow is configured to not apply updates, so update of information was skipped.");
73+
74+
return WorkflowExecutionStatus.Completed;
75+
}
76+
7077
var requestDto = new ContactDetailDto { Contact = Build(context.Record) };
7178

7279
if (contacts.Contacts.Count > 0) requestDto.Contact.Id = contacts.Contacts.First().Id;

src/Umbraco.Forms.Integrations.Crm.ActiveCampaign/Configuration/ActiveCampaignSettings.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ public ActiveCampaignSettings()
88
ContactFields = new List<ContactFieldSettings>();
99
}
1010

11-
public string BaseUrl { get; set; }
11+
public string BaseUrl { get; }
1212

13-
public string ApiKey { get; set; }
13+
public string ApiKey { get; }
14+
15+
public bool AllowContactUpdate { get; }
1416

1517
public List<ContactFieldSettings> ContactFields { get; set; }
1618
}
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
1+

72
namespace Umbraco.Forms.Integrations.Crm.Hubspot.Configuration
83
{
94
public class HubspotSettings
105
{
116
public string ApiKey { get; set; }
7+
8+
public bool AllowContactUpdate { get; }
129
}
1310
}

src/Umbraco.Forms.Integrations.Crm.Hubspot/Services/HubspotContactService.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ public async Task<CommandResult> PostContactAsync(Record record, List<MappedProp
202202
// A 409 - Conflict response indicates that the contact (by email address) already exists.
203203
if (response.StatusCode == HttpStatusCode.Conflict)
204204
{
205-
return await UpdateContactAsync(record, authenticationDetails, propertiesRequestV1, emailValue);
205+
if (!_settings.AllowContactUpdate)
206+
_logger.LogInformation("Contact already exists in HubSpot CRM and workflow is configured to not apply updates, so update of information was skipped.");
207+
return _settings.AllowContactUpdate
208+
? await UpdateContactAsync(record, authenticationDetails, propertiesRequestV1, emailValue)
209+
: CommandResult.Success;
206210
}
207211
else
208212
{

0 commit comments

Comments
 (0)