You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2026/09/10 11:19:51 UTC

(ofbiz-framework) branch release24.09 updated: Fixed: createLead person creation guard for company-only leads (OFBIZ-13549)

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 888ecb8e55 Fixed: createLead person creation guard for company-only leads (OFBIZ-13549)
888ecb8e55 is described below

commit 888ecb8e550021e1da5de5a61bff18ddbe5c9530
Author: Mridul Pathak <mr...@gmail.com>
AuthorDate: Thu Sep 10 16:35:32 2026 +0530

    Fixed: createLead person creation guard for company-only leads (OFBIZ-13549)
    
    - Gate person creation pipeline behind firstName and lastName check so company-only leads can be created without error
    - Fall back to partyGroupPartyId when associating data source if no person lead was created
---
 .../ofbiz/marketing/sfa/lead/LeadServices.groovy   | 35 ++++++++++++----------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/applications/marketing/src/main/groovy/org/apache/ofbiz/marketing/sfa/lead/LeadServices.groovy b/applications/marketing/src/main/groovy/org/apache/ofbiz/marketing/sfa/lead/LeadServices.groovy
index 5925eb57d7..4cbf4e452e 100644
--- a/applications/marketing/src/main/groovy/org/apache/ofbiz/marketing/sfa/lead/LeadServices.groovy
+++ b/applications/marketing/src/main/groovy/org/apache/ofbiz/marketing/sfa/lead/LeadServices.groovy
@@ -30,29 +30,32 @@ import java.sql.Timestamp
 Map createLead() {
     String leadContactPartyId
     String partyGroupPartyId
+    Map serviceResult
     // Check if Person or PartyGroup name is supplied
     if ((!parameters.firstName || !parameters.lastName) && !parameters.groupName) {
         return error(UtilProperties.getMessage('MarketingUiLabels', 'SfaFirstNameLastNameAndCompanyNameMissingError', locale))
     }
     run service: 'ensurePartyRole', with: [partyId: userLogin.partyId, roleTypeId: 'OWNER']
     // PartyRole check end
-    parameters.roleTypeId = 'LEAD'
+    if (parameters.firstName && parameters.lastName) {
+        parameters.roleTypeId = 'LEAD'
 
-    Map serviceResult = run service: 'createPersonRoleAndContactMechs', with: parameters
-    if (ServiceUtil.isError(serviceResult)) {
-        return serviceResult
-    }
-    leadContactPartyId = serviceResult.partyId
-    serviceResult = run service: 'createPartyRelationship', with: [partyIdFrom: userLogin.partyId,
-                                                                   partyIdTo: leadContactPartyId,
-                                                                   roleTypeIdFrom: 'OWNER',
-                                                                   roleTypeIdTo: 'LEAD',
-                                                                   partyRelationshipTypeId: 'LEAD_OWNER']
-    if (ServiceUtil.isError(serviceResult)) {
-        return serviceResult
+        serviceResult = run service: 'createPersonRoleAndContactMechs', with: parameters
+        if (ServiceUtil.isError(serviceResult)) {
+            return serviceResult
+        }
+        leadContactPartyId = serviceResult.partyId
+        serviceResult = run service: 'createPartyRelationship', with: [partyIdFrom: userLogin.partyId,
+                                                                       partyIdTo: leadContactPartyId,
+                                                                       roleTypeIdFrom: 'OWNER',
+                                                                       roleTypeIdTo: 'LEAD',
+                                                                       partyRelationshipTypeId: 'LEAD_OWNER']
+        if (ServiceUtil.isError(serviceResult)) {
+            return serviceResult
+        }
+        run service: 'setPartyStatus', with: [partyId: leadContactPartyId,
+                                              statusId: 'LEAD_ASSIGNED']
     }
-    run service: 'setPartyStatus', with: [partyId: leadContactPartyId,
-                                          statusId: 'LEAD_ASSIGNED']
 
     // Now create PartyGroup corresponding to the companyName, if its not null and then set up
     // relationship of Person and PartyGroup as Employee and title
@@ -98,7 +101,7 @@ Map createLead() {
     }
 
     if (parameters.dataSourceId) {
-        serviceResult = run service: 'createPartyDataSource', with: [partyId: leadContactPartyId,
+        serviceResult = run service: 'createPartyDataSource', with: [partyId: leadContactPartyId ?: partyGroupPartyId,
                                                                      dataSourceId: parameters.dataSourceId]
         if (ServiceUtil.isError(serviceResult)) {
             return serviceResult