Skip to content

Commit

Permalink
dev/core#5370 Fix bug handling soft credits in civi-import
Browse files Browse the repository at this point in the history
This ensures the userJob is saved at the js layer before the php layer kicks in.
If the js layer save does NOT run first it causes bugs like those
described in https://lab.civicrm.org/dev/core/-/issues/5370
  • Loading branch information
eileenmcnaughton committed Aug 8, 2024
1 parent ab1b555 commit c3f37a8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ext/civiimport/ang/crmCiviimport.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
* @type {$scope.save}
*/
$scope.save = (function ($event) {
$event.preventDefault();
$scope.userJob.metadata.entity_configuration = {};
$scope.userJob.metadata.import_mappings = [];
_.each($scope.entitySelection, function (entity) {
Expand All @@ -280,7 +281,16 @@
entity_data: entityConfig
});
});
crmApi4('UserJob', 'save', {records: [$scope.userJob]});
crmApi4('UserJob', 'save', {records: [$scope.userJob]})
.then(function(result) {
// Only post the form if the save succeeds.
document.getElementById("MapField").submit();
},
function(failure) {
// @todo add more error handling - for now, at least we waited...
document.getElementById("MapField").submit();
}
);
});

$scope.load();
Expand Down

0 comments on commit c3f37a8

Please sign in to comment.