This is an automated email from the ASF dual-hosted git repository.
mridulpathak 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 9493cc553d Fixed: Multiple regressions and one pre-existing bug in
WorkEffortServicesScript.groovy (OFBIZ-13601)
9493cc553d is described below
commit 9493cc553d0c3331a2c58c1b2cc85a1812120751
Author: Mridul Pathak <[email protected]>
AuthorDate: Sat Sep 19 18:03:22 2026 +0530
Fixed: Multiple regressions and one pre-existing bug in
WorkEffortServicesScript.groovy (OFBIZ-13601)
- checkAndCreateWorkEffort() referenced an undeclared variable
serviceResultAD
instead of serviceResult, throwing MissingPropertyException whenever a
shipment's estimated arrival date was set. Native Groovy since 2020, not a
minilang regression, but a real, live bug found in the same file.
- copyWorkEffort() called EntityUtil.filterByDate() unconditionally for
every
WorkEffort relation when excludeExpiredRelations='Y', crashing on
relations
(e.g. WorkEffortStatus) that have no fromDate field.
- assignPartyToWorkEffort()/updatePartyToWorkEffortAssignment() wrote
"statusDatetime" instead of the real WorkEffortPartyAssignment field
"statusDateTime", so the value was silently dropped and never persisted.
- quickAssignPartyToWorkEffort()/WithRole() were merged into one method that
always hardcoded statusId='PRTYASGN_ASSIGNED', losing the WithRole
variant's
intended 'CAL_ACCEPTED' status; split back into two methods to match.
Verified against the pre-conversion minilang and covered by temporary
RED/GREEN tests; full workeffort component suite passes.
---
applications/workeffort/servicedef/services.xml | 2 +-
.../workeffort/WorkEffortServicesScript.groovy | 24 +++++++++++++++++-----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/applications/workeffort/servicedef/services.xml
b/applications/workeffort/servicedef/services.xml
index 07a3862c94..0b7d6c60f2 100644
--- a/applications/workeffort/servicedef/services.xml
+++ b/applications/workeffort/servicedef/services.xml
@@ -258,7 +258,7 @@ under the License.
</type-validate>
</attribute>
</service>
- <service name="quickAssignPartyToWorkEffortWithRole" engine="groovy"
invoke="quickAssignPartyToWorkEffort"
+ <service name="quickAssignPartyToWorkEffortWithRole" engine="groovy"
invoke="quickAssignPartyToWorkEffortWithRole"
location="component://workeffort/src/main/groovy/org/apache/ofbiz/workeffort/workeffort/workeffort/WorkEffortServicesScript.groovy">
<description>Quick Assign Party To WorkEffort as Owner</description>
<attribute name="workEffortId" type="String" mode="IN">
diff --git
a/applications/workeffort/src/main/groovy/org/apache/ofbiz/workeffort/workeffort/workeffort/WorkEffortServicesScript.groovy
b/applications/workeffort/src/main/groovy/org/apache/ofbiz/workeffort/workeffort/workeffort/WorkEffortServicesScript.groovy
index 1c67a08be6..cd44efac31 100644
---
a/applications/workeffort/src/main/groovy/org/apache/ofbiz/workeffort/workeffort/workeffort/WorkEffortServicesScript.groovy
+++
b/applications/workeffort/src/main/groovy/org/apache/ofbiz/workeffort/workeffort/workeffort/WorkEffortServicesScript.groovy
@@ -80,7 +80,7 @@ Map checkAndCreateWorkEffort() {
if (!ServiceUtil.isSuccess(serviceResult)) {
return error(serviceResult.errorMessage)
}
- lookedUpValue.estimatedArrivalWorkEffId = serviceResultAD.workEffortId
+ lookedUpValue.estimatedArrivalWorkEffId = serviceResult.workEffortId
if (parameters.partyIdTo) {
serviceResult = run service: 'assignPartyToWorkEffort', with:
[workEffortId: lookedUpValue.estimatedArrivalWorkEffId,
partyId:
parameters.partyIdTo,
@@ -324,7 +324,7 @@ Map copyWorkEffort() {
if (keyMap) {
String relationWorkEffortId = keyMap.getRelFieldName()
List<GenericValue> relationValues =
sourceWorkEffort.getRelated(relationName, null, null, false)
- if (parameters.excludeExpiredRelations == 'Y') {
+ if (parameters.excludeExpiredRelations == 'Y' &&
delegator.getModelEntity(it.getRelEntityName()).getField('fromDate')) {
relationValues =
EntityUtil.filterByDate(relationValues)
}
relationValues.each { relationValue ->
@@ -409,7 +409,7 @@ Map duplicateWorkEffort() {
*/
void duplicateWorkEffortAssoc(String relationEntityName, String
oldWorkEffortId,
String workEffortId, String relationFieldName =
'workEffortId') {
- ModelEntity modelEntity = delegator.getModelEntity(relationFieldName)
+ ModelEntity modelEntity = delegator.getModelEntity(relationEntityName)
EntityQuery entities = from(relationEntityName)
.where((relationFieldName): oldWorkEffortId)
if (modelEntity.getField('fromDate')) {
@@ -473,7 +473,7 @@ Map assignPartyToWorkEffort() {
Timestamp now = UtilDateTime.nowTimestamp()
parameters.fromDate = parameters.fromDate ?: now
Map result = run service: 'createWorkEffortPartyAssignment', with: [*:
parameters,
-
statusDatetime: parameters.statusId ? now : null,
+
statusDateTime: parameters.statusId ? now : null,
assignedByUserLoginId: userLogin.userLoginId]
assignment = from('WorkEffortPartyAssignment').where(parameters).queryOne()
if (parameters.statusId) {
@@ -491,7 +491,7 @@ Map updatePartyToWorkEffortAssignment() {
if (assignment && parameters.statusId
&& parameters.statusId != assignment.statusId) {
WorkEffortPartyAssignmentServices.updateWorkflowEngine(assignment,
userLogin, dispatcher)
- parameters.statusDatetime = UtilDateTime.nowTimestamp()
+ parameters.statusDateTime = UtilDateTime.nowTimestamp()
}
Map result = run service: 'updateWorkEffortPartyAssignment', with:
parameters
return result
@@ -511,6 +511,20 @@ Map quickAssignPartyToWorkEffort() {
return success()
}
+/**
+ * Quick Assign Party To WorkEffort with an explicit role
+ * @return Success, error response otherwise.
+ */
+Map quickAssignPartyToWorkEffortWithRole() {
+ // add a party assignment for the creator of the event, use the list
method and let the EE do the update or create...
+ run service: 'ensurePartyRole', with: [partyId:
parameters.quickAssignPartyId,
+ roleTypeId: parameters.roleTypeId]
+ run service: 'createWorkEffortPartyAssignment', with: [*: parameters,
+ partyId:
parameters.quickAssignPartyId,
+ statusId:
'CAL_ACCEPTED']
+ return success()
+}
+
/**
* Quick Assign Party To WorkEffort
* if relationEntityName is present create the contactMech type related