This is an automated email from the ASF dual-hosted git repository.

nmalin pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release24.09 by this push:
     new 397da35ef1 Fixed: Update communication event failed if statusId is 
null (OFBIZ-13258)
397da35ef1 is described below

commit 397da35ef1504f8c437720eb6121d2fa67ad153d
Author: Nicolas Malin <nicolas.ma...@nereide.fr>
AuthorDate: Wed Jun 11 10:40:16 2025 +0200

    Fixed: Update communication event failed if statusId is null (OFBIZ-13258)
    
    When you updated a communication event and you move it statusId from null 
to another value, function setCommunicationEventStatus failed because it tried 
to valid the status change with null value.
    
    By the way, error message sent to user didn't work after the minilang to 
groovy migration
---
 .../CommunicationEventServicesScript.groovy        | 47 ++++++++++++----------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git 
a/applications/party/src/main/groovy/org/apache/ofbiz/party/communication/CommunicationEventServicesScript.groovy
 
b/applications/party/src/main/groovy/org/apache/ofbiz/party/communication/CommunicationEventServicesScript.groovy
index 7aef405a43..c17076757c 100644
--- 
a/applications/party/src/main/groovy/org/apache/ofbiz/party/communication/CommunicationEventServicesScript.groovy
+++ 
b/applications/party/src/main/groovy/org/apache/ofbiz/party/communication/CommunicationEventServicesScript.groovy
@@ -513,17 +513,18 @@ Map setCommunicationEventStatus() {
     GenericValue communicationEvent = from('CommunicationEvent')
             .where(parameters)
             .queryOne()
-    oldStatusId = communicationEvent.statusId
-
-    if (parameters.statusId != communicationEvent.statusId) {
-        GenericValue statusChange = from('StatusValidChange')
-                .where(statusId: communicationEvent.statusId,
-                        statusIdTo: parameters.statusId)
-                .queryOne()
-        if (!statusChange) {
-            logError("Cannot change from ${communicationEventRole.statusId} to 
${parameters.statusId}")
-            return error(UtilProperties.getMessage('ProductUiLabels',
-                            'commeventservices.communication_event_status', 
parameters.locale as Locale))
+    String oldStatusId = communicationEvent.statusId
+    if (parameters.statusId != oldStatusId) {
+        if (oldStatusId) {
+            GenericValue statusChange = from('StatusValidChange')
+                    .where(statusId: oldStatusId,
+                            statusIdTo: parameters.statusId)
+                    .queryOne()
+            if (!statusChange) {
+                logError("Cannot change from ${oldStatusId} to 
${parameters.statusId}")
+                return error(label('PartyErrorUiLabels', 
'commeventservices.communication_event_status',
+                        [parameters: parameters, communicationEvent: 
communicationEvent]))
+            }
         }
         communicationEvent.statusId = parameters.statusId
         communicationEvent.store()
@@ -596,17 +597,19 @@ Map setCommunicationEventRoleStatus() {
             .where(parameters)
             .queryOne()
 
-    oldStatusId = communicationEventRole.statusId
-    if (parameters.statusId != communicationEventRole.statusId) {
-        GenericValue statusChange = from('StatusValidChange')
-                .where(statusId: communicationEventRole.statusId,
-                        statusIdTo: parameters.statusId)
-                .cache()
-                .queryOne()
-        if (!statusChange) {
-            logError("Cannot change from ${communicationEventRole.statusId} to 
${parameters.statusId}")
-            return error(UtilProperties.getMessage('ProductUiLabels',
-                            'commeventservices.communication_event_status', 
parameters.locale as Locale))
+    String oldStatusId = communicationEventRole.statusId
+    if (parameters.statusId != oldStatusId) {
+        if (oldStatusId) {
+            GenericValue statusChange = from('StatusValidChange')
+                    .where(statusId: oldStatusId,
+                            statusIdTo: parameters.statusId)
+                    .cache()
+                    .queryOne()
+            if (!statusChange) {
+                logError("Cannot change from ${oldStatusId} to 
${parameters.statusId}")
+                return error(label('PartyErrorUiLabels', 
'commeventservices.communication_event_role_status',
+                        [parameters: parameters, communicationEventRole: 
communicationEventRole]))
+            }
         }
         communicationEventRole.statusId = parameters.statusId
         communicationEventRole.store()

Reply via email to