Skip to content

Commit 9eb9a38

Browse files
committed
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
1 parent 6259d18 commit 9eb9a38

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

applications/party/src/main/groovy/org/apache/ofbiz/party/communication/CommunicationEventServicesScript.groovy

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -513,17 +513,18 @@ Map setCommunicationEventStatus() {
513513
GenericValue communicationEvent = from('CommunicationEvent')
514514
.where(parameters)
515515
.queryOne()
516-
oldStatusId = communicationEvent.statusId
517-
518-
if (parameters.statusId != communicationEvent.statusId) {
519-
GenericValue statusChange = from('StatusValidChange')
520-
.where(statusId: communicationEvent.statusId,
521-
statusIdTo: parameters.statusId)
522-
.queryOne()
523-
if (!statusChange) {
524-
logError("Cannot change from ${communicationEventRole.statusId} to ${parameters.statusId}")
525-
return error(UtilProperties.getMessage('ProductUiLabels',
526-
'commeventservices.communication_event_status', parameters.locale as Locale))
516+
String oldStatusId = communicationEvent.statusId
517+
if (parameters.statusId != oldStatusId) {
518+
if (oldStatusId) {
519+
GenericValue statusChange = from('StatusValidChange')
520+
.where(statusId: oldStatusId,
521+
statusIdTo: parameters.statusId)
522+
.queryOne()
523+
if (!statusChange) {
524+
logError("Cannot change from ${oldStatusId} to ${parameters.statusId}")
525+
return error(label('PartyErrorUiLabels', 'commeventservices.communication_event_status',
526+
[parameters: parameters, communicationEvent: communicationEvent]))
527+
}
527528
}
528529
communicationEvent.statusId = parameters.statusId
529530
communicationEvent.store()
@@ -596,17 +597,19 @@ Map setCommunicationEventRoleStatus() {
596597
.where(parameters)
597598
.queryOne()
598599

599-
oldStatusId = communicationEventRole.statusId
600-
if (parameters.statusId != communicationEventRole.statusId) {
601-
GenericValue statusChange = from('StatusValidChange')
602-
.where(statusId: communicationEventRole.statusId,
603-
statusIdTo: parameters.statusId)
604-
.cache()
605-
.queryOne()
606-
if (!statusChange) {
607-
logError("Cannot change from ${communicationEventRole.statusId} to ${parameters.statusId}")
608-
return error(UtilProperties.getMessage('ProductUiLabels',
609-
'commeventservices.communication_event_status', parameters.locale as Locale))
600+
String oldStatusId = communicationEventRole.statusId
601+
if (parameters.statusId != oldStatusId) {
602+
if (oldStatusId) {
603+
GenericValue statusChange = from('StatusValidChange')
604+
.where(statusId: oldStatusId,
605+
statusIdTo: parameters.statusId)
606+
.cache()
607+
.queryOne()
608+
if (!statusChange) {
609+
logError("Cannot change from ${oldStatusId} to ${parameters.statusId}")
610+
return error(label('PartyErrorUiLabels', 'commeventservices.communication_event_role_status',
611+
[parameters: parameters, communicationEventRole: communicationEventRole]))
612+
}
610613
}
611614
communicationEventRole.statusId = parameters.statusId
612615
communicationEventRole.store()

0 commit comments

Comments
 (0)