Skip to content

Commit 89563c7

Browse files
committed
Add feature to allow contact field value append.
1 parent 5e4e953 commit 89563c7

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/Umbraco.Forms.Integrations.Crm.Hubspot/App_Plugins/UmbracoForms.Integrations/Crm/Hubspot/hubspot-field-mapper-template.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<div class="umb-forms-mapping-header">
2525
<div class="umb-forms-mapping-field -no-margin-left">Form Field</div>
2626
<div class="umb-forms-mapping-field">Hubspot Field</div>
27+
<div class="umb-forms-mapping-field text-center">Append when updating values</div>
2728
<div class="umb-forms-mapping-remove -no-margin-right"></div>
2829
</div>
2930

@@ -46,6 +47,14 @@
4647
</select>
4748
</div>
4849

50+
<div class="umb-forms-mapping-field flex justify-center">
51+
<umb-checkbox name="chkAppend"
52+
value="mapping.appendValue"
53+
model="mapping.appendValue"
54+
on-change="vm.stringifyValue()">
55+
</umb-checkbox>
56+
</div>
57+
4958
<div class="umb-forms-mapping-remove -no-margin-right">
5059
<a href="" ng-click="vm.deleteMapping($index)"><i class="icon-trash"></i></a>
5160
</div>

src/Umbraco.Forms.Integrations.Crm.Hubspot/App_Plugins/UmbracoForms.Integrations/Crm/Hubspot/hubspotfields.component.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function HubSpotFieldsController($scope, $routeParams, umbracoFormsIntegrationsC
5656
if (!vm.setting.value) {
5757
vm.mappings = [];
5858
} else {
59-
vm.mappings = JSON.parse(vm.setting.value);
59+
vm.getParsedMappings();
6060
}
6161

6262
umbracoFormsIntegrationsCrmHubspotResource.isAuthorizationConfigured().then(function (response) {
@@ -178,7 +178,8 @@ function HubSpotFieldsController($scope, $routeParams, umbracoFormsIntegrationsC
178178
// Add new empty object into the mappings array.
179179
vm.mappings.push({
180180
formField: "",
181-
hubspotField: ""
181+
hubspotField: "",
182+
appendValue: false
182183
});
183184
};
184185

@@ -190,4 +191,14 @@ function HubSpotFieldsController($scope, $routeParams, umbracoFormsIntegrationsC
190191
vm.stringifyValue = function () {
191192
vm.setting.value = JSON.stringify(vm.mappings);
192193
};
194+
195+
vm.getParsedMappings = function () {
196+
var mappings = JSON.parse(vm.setting.value);
197+
vm.mappings = mappings.map(mappingObj => {
198+
if (mappingObj.appendValue === undefined) {
199+
mappingObj.appendValue = false;
200+
}
201+
return mappingObj;
202+
});
203+
}
193204
}

src/Umbraco.Forms.Integrations.Crm.Hubspot/Models/MappedProperty.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ public class MappedProperty
99

1010
[JsonProperty(PropertyName = "hubspotField")]
1111
public string HubspotField { get; set; }
12+
13+
[JsonProperty(PropertyName = "appendValue")]
14+
public bool AppendValue { get; set; }
1215
}
1316
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ public async Task<CommandResult> PostContactAsync(Record record, List<MappedProp
160160
var recordField = record.GetRecordField(Guid.Parse(fieldId));
161161
if (recordField != null)
162162
{
163-
var value = recordField.ValuesAsHubspotString(false);
163+
var value = _settings.AllowContactUpdate && mapping.AppendValue
164+
? ";" + recordField.ValuesAsHubspotString(false)
165+
: recordField.ValuesAsHubspotString(false);
164166

165167
propertiesRequestV1.Properties.Add(new PropertiesRequestV1.PropertyValue(mapping.HubspotField, value));
166168
propertiesRequestV3.Properties.Add(mapping.HubspotField, value);

0 commit comments

Comments
 (0)