diff --git a/applications/party/servicedef/services.xml b/applications/party/servicedef/services.xml
index 1967e03e12..42ec441cce 100644
--- a/applications/party/servicedef/services.xml
+++ b/applications/party/servicedef/services.xml
@@ -939,7 +939,8 @@ under the License.
- Sets the status of a communication event to COM_COMPLETE using the updateCommunicationEvent service
+ Sets the status of a communication event to COM_COMPLETE using the updateCommunicationEvent service,
+ set datetimeEnded to now if not defined
diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java
index 41721bafa0..e5ab27b26d 100644
--- a/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java
+++ b/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java
@@ -508,17 +508,27 @@ public class CommunicationEventServices {
public static Map setCommEventComplete(DispatchContext dctx, Map context) {
LocalDispatcher dispatcher = dctx.getDispatcher();
+ Delegator delegator = dctx.getDelegator();
GenericValue userLogin = (GenericValue) context.get("userLogin");
String communicationEventId = (String) context.get("communicationEventId");
String partyIdFrom = (String) context.get("partyIdFrom");
try {
+ GenericValue communicationEvent = delegator.findOne("CommunicationEvent", true, "communicationEventId", communicationEventId);
+ if (communicationEvent == null) {
+ return ServiceUtil.returnError(UtilProperties.getMessage("PartyUiLabels", "PartyCommunicationEventNotFound",
+ UtilMisc.toMap("communicationEventId", communicationEventId), (Locale) context.get("locale")));
+ }
+ Timestamp endDate = communicationEvent.getTimestamp("datetimeEnded");
+ if (endDate == null) {
+ endDate = UtilDateTime.nowTimestamp();
+ }
Map result = dispatcher.runSync("updateCommunicationEvent", UtilMisc.toMap("communicationEventId", communicationEventId,
- "partyIdFrom", partyIdFrom, "statusId", "COM_COMPLETE", "userLogin", userLogin));
+ "partyIdFrom", partyIdFrom, "statusId", "COM_COMPLETE", "datetimeEnded", endDate, "userLogin", userLogin));
if (ServiceUtil.isError(result)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
}
- } catch (GenericServiceException esx) {
+ } catch (GeneralException esx) {
return ServiceUtil.returnError(esx.getMessage());
}