String contactMechId = (String) context.get("contactMechId");
String contactMechPurposeTypeId = (String) context.get("contactMechPurposeTypeId");
GenericValue tempVal = null;
try {
Map<String, String> pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId);
<BUG>List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", pcmpFindMap, null, false), true);

tempVal = EntityUtil.getFirst(allPCMPs);
</BUG>
} catch (GenericEntityException e) {

String contactMechId = (String) context.get("contactMechId");
String contactMechPurposeTypeId = (String) context.get("contactMechPurposeTypeId");
Timestamp fromDate = (Timestamp) context.get("fromDate");
GenericValue tempVal = null;
try {
Map<String, String> pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId);
List<GenericValue> allPCWPs = delegator.findByAnd("PartyContactWithPurpose", pcmpFindMap, null, false);
allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "contactFromDate", "contactThruDate", true);
allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "purposeFromDate", "purposeThruDate", true);
tempVal = EntityUtil.getFirst(allPCWPs);
} catch (GenericEntityException e) {
