1

I have a lookup field in visualforce page, and upon selecting a value from "my recent item" it should populate that value in the lookup field. But, instead, it throws "Error: Multiple items found. Select from drop-down or click icon to refine search". on Standard Page it will select the actual value and give you the record.

on the lookup field i have a onchange event which calls another actionsupport function.

<apex:actionfunction name="loaduserdetails" action="{!UserDetails}" rerender="frm"/>
<apex:inputField value="{!acc.OwnerId}" label="test" onChange="loaduserdetails()"/>

This might be causing the issue but i wanted to be sure. So i bring up to the community.

enter image description here

2 Answers 2

0

If there are multiple records available with the entered partial value in the text box, it gives you that error. This even happens in Standard page.

In standard page, the error would come up when you click on save as the entered data is sent to server only when you save. Where as in your Visualforce page, as you added "onchange" event, it immediately sends the data to server and validates.

And, as you mentioned its happening upon selecting from the list, here the issue could be that the onChange javascript function is triggered before the value gets updated upon your selection.

in this case, one possible option is to write the server action in RemoteAction and call it through Javascript.

1
  • thanks for replying, but i think you misread my question. I agree if there are multiple records exists with same firstName per say, and errors out that's fine. But when you select from "my recent items " (only one Name) that should be the value of the field right ? on the lookup field it shouldn't search with string i entered in the field. I will dig more in onchange as you suggested javascript might be triggering the search. I will post my findings here soon, thanks for pointing that out. Jan 24, 2018 at 23:09
0

looks like onchange event is causing the issue, and i changed it to onselect and it worked just fine.

<apex:inputField value="{!acc.OwnerId}" label="test" onSelect="loaduserdetails()"/>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .