Summary:

A SQL error may be logged when matching a lead against a Company record. This issue is caused by an error processing match rules for the Person entity, when no person details are associated with the lead. This issue is reproducible in Sage CRM 7.2, or versions of Sage CRM 7.3 prior to patch C.

Symptoms:

After creating a new Lead record, a user can either create a new Company record, or match it to an existing Company in the system. On selecting the Company record, the following error message is displayed:

An unexpected event has occurred: SQL Code: 102
Exception: SQL Error

The eWare SQL logs show the following:

Sep 7 2015 10:20:10.655 227104 228064 1 fselectsql,time,sql,errormsg 421 select Pers_PersonID from vSearchListPerson where Pers_PersonId = 57 AND  Incorrect syntax near 'AND'

Cause:

The issue is caused by a lack of valid match rules on the Person entity. A similar issue may be experienced when the lead's Person fields are hidden.

Resolution:

This issue was raised as a bug to the development team, and was resolved in the Sage CRM 7.3c patch, released on August 31st, 2015. The case references is 0-164289-QA.

For earlier versions of Sage CRM, the issue can be worked around by doing the following:

  1. Go to Administration | System Behaviour and set Deduplication to Yes.
  2. Go to Administration | Data Management and select the Match Rules menu.
  3. Select the Person option and select Continue.
  4. Add new Exact match rules for pers_lastname and pers_firstname.
  5. Go to Administration | System Behaviour and set Deduplication to No.

In the case where the Person fields are hidden, the above will not work. The issue will still be reproducible when there are no match rules, or when there exist match rules for a PErson field that is not present on LeadPersonScreen.

An alternative workaround exists whereby the following Custom Content script can be added to CompanyBoxLong:

<script>
crm.ready(function () {

    console.log ("Workaround for Sage CRM L3 case 0-164289-QA");

    var urlMatch = /Act=200.*fromWebPicker=TRUE/gi

    if (urlMatch.test(document.location.href)) {
   
        $(".ButtonItem").each(

            function () {
       
                if ( ($(this).attr("onclick") + "").indexOf("vUpdatePersonID") > -1 ) {
       
                    var newFunc = ($(this).attr("onclick") + "").replace(/\&vUpdatePersonID=[0-9]+/, '');
           
                    $(this).click( function () { eval (newFunc); } );
                }
            }
        );
    }
});
</script>