Author: apatel
Date: Wed Jun 24 06:14:43 2009 New Revision: 787920 URL: http://svn.apache.org/viewvc?rev=787920&view=rev Log: Updated convert lead service to expire relationships. Converting a lead now requires contact person id and partyGroupId. Modified: ofbiz/trunk/applications/marketing/script/org/ofbiz/sfa/lead/LeadServices.xml ofbiz/trunk/applications/marketing/servicedef/services.xml ofbiz/trunk/applications/marketing/widget/sfa/forms/LeadForms.xml Modified: ofbiz/trunk/applications/marketing/script/org/ofbiz/sfa/lead/LeadServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/script/org/ofbiz/sfa/lead/LeadServices.xml?rev=787920&r1=787919&r2=787920&view=diff ============================================================================== --- ofbiz/trunk/applications/marketing/script/org/ofbiz/sfa/lead/LeadServices.xml (original) +++ ofbiz/trunk/applications/marketing/script/org/ofbiz/sfa/lead/LeadServices.xml Wed Jun 24 06:14:43 2009 @@ -123,56 +123,101 @@ </simple-method> <simple-method method-name="convertLeadToContact" short-description="Convert a lead person into a contact and associated lead group to an account"> - <set field="createPartyRoleCtx.partyId" from-field="parameters.partyId"/> - <set field="createPartyRoleCtx.roleTypeId" value="CONTACT"/> - <call-service service-name="createPartyRole" in-map-name="createPartyRoleCtx"/> + <set field="partyId" from-field="parameters.partyId"/> + <set field="partyGroupId" from-field="parameters.partyGroupId"/> + <now-timestamp field="nowTimestamp"/> <entity-and entity-name="PartyRelationship" list="partyRelationships" filter-by-date="true"> - <field-map field-name="partyIdTo" from-field="parameters.partyId"/> + <field-map field-name="partyIdTo" from-field="partyId"/> + <field-map field-name="roleTypeIdFrom" value="OWNER"/> <field-map field-name="roleTypeIdTo" value="LEAD"/> - <field-map field-name="roleTypeIdFrom" value="ACCOUNT_LEAD"/> + <field-map field-name="partyRelationshipTypeId" value="LEAD_OWNER"/> <order-by field-name="-fromDate"/> </entity-and> <first-from-list list="partyRelationships" entry="partyRelationship"/> + <if-not-empty field="partyRelationship"> + <set-service-fields service-name="updatePartyRelationship" map="partyRelationship" to-map="deletePartyRelationship"/> + <set from-field="nowTimestamp" field="deletePartyRelationship.thruDate"/> + <call-service service-name="updatePartyRelationship" in-map-name="deletePartyRelationship"/> + <log level="info" message="Expiring relationship ${deletePartyRelationship}"> </log> + <clear-field field="deletePartyRelationship"/> + <clear-field field="partyRelationship"/> + </if-not-empty> + + <!-- Expire relation between lead company and lead person --> + <entity-and entity-name="PartyRelationship" list="partyRelationships" filter-by-date="true"> + <field-map field-name="partyIdFrom" from-field="partyGroupId"/> + <field-map field-name="roleTypeIdTo" value="LEAD"/> + <field-map field-name="roleTypeIdFrom" value="ACCOUNT_LEAD"/> + <field-map field-name="partyRelationshipTypeId" value="EMPLOYMENT"/> + <order-by field-name="-fromDate"/> + </entity-and> + <first-from-list list="partyRelationships" entry="partyRelationship"/> <if-not-empty field="partyRelationship"> <set-service-fields service-name="updatePartyRelationship" map="partyRelationship" to-map="deletePartyRelationship"/> <set from-field="nowTimestamp" field="deletePartyRelationship.thruDate"/> <call-service service-name="updatePartyRelationship" in-map-name="deletePartyRelationship"/> - <set field="partyGroupId" from-field="partyRelationship.partyIdFrom"/> - <else> - <set field="partyGroupId" from-field="parameters.partyGroupId"/> - </else> + + <log level="info" message="Expiring relationship ${deletePartyRelationship}"> </log> + <clear-field field="deletePartyRelationship"/> + <clear-field field="partyRelationship"/> </if-not-empty> - <if-empty field="partyGroupId"> - <add-error><fail-message message="Party Group ID not found in realtionship AND not supplied"/></add-error> - </if-empty> - <check-errors/> + <!-- Expire relation between lead company and its owner --> + <entity-and entity-name="PartyRelationship" list="partyRelationships" filter-by-date="true"> + <field-map field-name="partyIdFrom" from-field="userLogin.partyId"/> + <field-map field-name="partyIdTo" from-field="partyGroupPartyId"/> + <field-map field-name="roleTypeIdTo" value="ACCOUNT_LEAD"/> + <field-map field-name="roleTypeIdFrom" value="OWNER"/> + <order-by field-name="-fromDate"/> + </entity-and> + <first-from-list list="partyRelationships" entry="partyRelationship"/> + <if-not-empty field="partyRelationship"> + <set-service-fields service-name="updatePartyRelationship" map="partyRelationship" to-map="deletePartyRelationship"/> + <set from-field="nowTimestamp" field="deletePartyRelationship.thruDate"/> + <call-service service-name="updatePartyRelationship" in-map-name="deletePartyRelationship"/> + <log level="info" message="Expiring relationship ${deletePartyRelationship}"> </log> + <clear-field field="deletePartyRelationship"/> + <clear-field field="partyRelationship"/> + </if-not-empty> <set field="partyRoleCtx.partyId" from-field="partyGroupId"/> <set field="partyRoleCtx.roleTypeId" value="ACCOUNT"/> <call-service service-name="createPartyRole" in-map-name="partyRoleCtx"/> - <!-- create new relationship --> - <set field="partyRelationshipCtx.partyIdFrom" from-field="partyGroupId"/> - <set field="partyRelationshipCtx.roleTypeIdFrom" value="ACCOUNT"/> - <set field="partyRelationshipCtx.partyIdTo" from-field="parameters.partyId"/> - <set field="partyRelationshipCtx.roleTypeIdTo" value="CONTACT"/> - <set field="partyRelationshipCtx.partyRelationshipTypeId" value="EMPLOYMENT"/> - <call-service service-name="createPartyRelationship" in-map-name="partyRelationshipCtx"/> - <set field="partyRelationshipCtx.partyIdFrom" from-field="userLogin.partyId"/> <set field="partyRelationshipCtx.partyIdTo" from-field="partyGroupId"/> <set field="partyRelationshipCtx.roleTypeIdFrom" value="OWNER"/> <set field="partyRelationshipCtx.roleTypeIdTo" value="ACCOUNT"/> <set field="partyRelationshipCtx.partyRelationshipTypeId" value="ACCOUNT"/> <call-service service-name="createPartyRelationship" in-map-name="partyRelationshipCtx"/> + <log level="info" message="Creating relationship ${partyRelationshipCtx}"> </log> + <clear-field field="partyRelationshipCtx"/> + + <set field="updatePartyCtx.partyId" from-field="partyGroupId"/> + <set field="updatePartyCtx.statusId" value="LEAD_CONVERTED"/> + <call-service service-name="setPartyStatus" in-map-name="updatePartyCtx"/> + + <set field="createPartyRoleCtx.partyId" from-field="partyId"/> + <set field="createPartyRoleCtx.roleTypeId" value="CONTACT"/> + <call-service service-name="createPartyRole" in-map-name="createPartyRoleCtx"/> + <!-- create new relationship between new account and contact person there --> + <set field="partyRelationshipCtx.partyIdFrom" from-field="partyGroupId"/> + <set field="partyRelationshipCtx.roleTypeIdFrom" value="ACCOUNT"/> + <set field="partyRelationshipCtx.partyIdTo" from-field="partyId"/> + <set field="partyRelationshipCtx.roleTypeIdTo" value="CONTACT"/> + <set field="partyRelationshipCtx.partyRelationshipTypeId" value="EMPLOYMENT"/> + <call-service service-name="createPartyRelationship" in-map-name="partyRelationshipCtx"/> + - <set field="updatePartyCtx.partyId" from-field="parameters.partyId"/> + <log level="info" message="Creating relationship ${partyRelationshipCtx}"> </log> + <clear-field field="partyRelationshipCtx"/> + <set field="updatePartyCtx.partyId" from-field="partyId"/> <set field="updatePartyCtx.statusId" value="LEAD_CONVERTED"/> <call-service service-name="setPartyStatus" in-map-name="updatePartyCtx"/> - <field-to-result field="parameters.partyId" result-name="partyId"/> + + <field-to-result field="partyId"/> <field-to-result field="partyGroupId"/> - <set field="successMessage" value="Lead ${parameters.partyId} succesfully converted to contact"/> + <set field="successMessage" value="Lead ${partyId} ${partyGroupId} succesfully converted to Account/Contact"/> </simple-method> </simple-methods> Modified: ofbiz/trunk/applications/marketing/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/servicedef/services.xml?rev=787920&r1=787919&r2=787920&view=diff ============================================================================== --- ofbiz/trunk/applications/marketing/servicedef/services.xml (original) +++ ofbiz/trunk/applications/marketing/servicedef/services.xml Wed Jun 24 06:14:43 2009 @@ -472,8 +472,7 @@ </service> <service name="convertLeadToContact" engine="simple" location="component://marketing/script/org/ofbiz/sfa/lead/LeadServices.xml" invoke="convertLeadToContact"> <attribute name="partyId" type="String" mode="INOUT" optional="false"/> - <attribute name="partyGroupId" type="String" mode="IN" optional="true"/> - <attribute name="partyGroupId" type="String" mode="OUT" optional="false"/> + <attribute name="partyGroupId" type="String" mode="INOUT" optional="false"/> </service> <!-- VCard services --> Modified: ofbiz/trunk/applications/marketing/widget/sfa/forms/LeadForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/widget/sfa/forms/LeadForms.xml?rev=787920&r1=787919&r2=787920&view=diff ============================================================================== --- ofbiz/trunk/applications/marketing/widget/sfa/forms/LeadForms.xml (original) +++ ofbiz/trunk/applications/marketing/widget/sfa/forms/LeadForms.xml Wed Jun 24 06:14:43 2009 @@ -81,7 +81,7 @@ <display-entity also-hidden="false" entity-name="PartyNameView" key-field-name="partyId" description="${groupName}${firstName} ${lastName} [${parameters.partyId}]"/> </field> <field name="partyGroupId" title="${uiLabelMap.SfaCreateAccountForLead}" use-when="parameters.get("partyGroupId")!="""> - <display-entity also-hidden="false" entity-name="PartyNameView" key-field-name="partyId" description="${groupName}${firstName} ${lastName} [${parameters.partyGroupId}]"/> + <display-entity also-hidden="true" entity-name="PartyNameView" key-field-name="partyId" description="${groupName}${firstName} ${lastName} [${parameters.partyGroupId}]"/> </field> <field name="partyGroupId" title="${uiLabelMap.SfaAccountName}" tooltip="${uiLabelMap.SfaSelectExistingAccountOrLeaveBlankToCreateNew}" use-when="parameters.get("partyGroupId")=="""> <drop-down allow-empty="true" current-description=""> |
Free forum by Nabble | Edit this page |