4

I have a visual force page where I had to define a look up to Contact. So I used contact.ReportsToId like below

<apex:outputLabel value="Select Requestor:" for="requestor"/>
<apex:inputField id="requestor" value="{!contact.ReportsToId}" onChange="redirectToExternal(this)"/>

onChange of the look up field, I am executing a javascript with takes ele.value and routes it to a different VF page. So if I select Priyanka C Sharma as contact .. Priyanka C Sharma would be passed along.

Now in the second page, I need to query contact by its name.

 Contact c = [select id from Contact where Name='Priyanka C Sharma'];

Here contact returns null, as I am not able to query name by its middlename. If its just Priyanka Sharma(FirstName+''+LastName) I am able to query the contact.

Any workarounds for this? How will I be able to query contact by its name field when middlename is entered?

0

I ran into this issue and it was only impacting my full copy sandbox (not production).

Example REPRO

Contact c = [SELECT FirstName, LastName FROM Contact WHERE Id = '0031J00001Hewjy'];
System.debug(c);
Contact c2 = [SELECT FirstName, LastName FROM Contact WHERE FirstName = :c.FirstName AND LastName = :c.LastName];
System.debug(c2);

RESULT:

01:52:32.1 (2478415)|SOQL_EXECUTE_BEGIN|[1]|Aggregations:0|SELECT FirstName, LastName FROM Contact WHERE Id = '0031J00001Hewjy'
01:52:32.1 (6281865)|SOQL_EXECUTE_END|[1]|Rows:1
01:52:32.1 (6663245)|USER_DEBUG|[2]|DEBUG|Contact:{FirstName=John, LastName=Doe, Id=0031J00001HewjyQAB, RecordTypeId=0121J000000uGo4QAE}
01:52:32.1 (7018840)|SOQL_EXECUTE_BEGIN|[3]|Aggregations:0|SELECT FirstName, LastName FROM Contact WHERE (FirstName = :tmpVar1 AND LastName = :tmpVar2)
01:52:32.1 (23897860)|SOQL_EXECUTE_END|[3]|Rows:0
01:52:32.1 (24425335)|FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject

AnonymousBlock: line 3, column 1

Seems like a bad index from the sandbox copy or something. If I updated the First Name it seemed to resolve the issue for that particular record.

-2

You're right. That is a bug in the software. Please log a case so that Salesforce can get this bug assigned.

  • 5
    Do you work for Salesforce? How did you confirm this was a bug? – Mark Pond Sep 4 '15 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.