diff --git a/src/Comsave/SalesforceOutboundMessageBundle/Services/RequestHandler/SoapRequestHandler.php b/src/Comsave/SalesforceOutboundMessageBundle/Services/RequestHandler/SoapRequestHandler.php index 4e8d947..ae14ad2 100644 --- a/src/Comsave/SalesforceOutboundMessageBundle/Services/RequestHandler/SoapRequestHandler.php +++ b/src/Comsave/SalesforceOutboundMessageBundle/Services/RequestHandler/SoapRequestHandler.php @@ -121,6 +121,8 @@ public function process($sObject) $mappedDocument = $this->mapper->mapToDomainObject($sObject, $this->documentClassName); $existingDocument = $this->documentManager->find($this->documentClassName, $mappedDocument->getId()); + $this->mapInitialDocumentValues($mappedDocument, $existingDocument); + if ($this->isForceCompared && $existingDocument && $this->objectComparator->equals( @@ -131,8 +133,7 @@ public function process($sObject) return; } - $allowedProperties = $this->getAllowedProperties($this->documentClassName); - $this->documentUpdater->updateWithDocument($mappedDocument, $existingDocument, null, $allowedProperties); + $this->mapInitialDocumentValues(); $beforeFlushEvent = $this->outboundMessageBeforeFlushEventBuilder->build($mappedDocument, $existingDocument); $this->eventDispatcher->dispatch(OutboundMessageBeforeFlushEvent::NAME, $beforeFlushEvent); @@ -157,6 +158,14 @@ public function process($sObject) $this->eventDispatcher->dispatch(OutboundMessageAfterFlushEvent::NAME, $afterFlushEvent); } + public function mapInitialDocumentValues($mappedDocument, $existingDocument): void + { + if($existingDocument) { + $allowedProperties = $this->getAllowedProperties($this->documentClassName); + $this->documentUpdater->updateWithDocument($mappedDocument, $existingDocument, null, $allowedProperties); + } + } + public function getAllowedProperties(string $documentClass): array { /** @var Field[]|ArrayCollection|null $salesforceFields */