I would like to limit the lookup field to only show the currently logged in user as an option. .
I tried this but it didn’t work for me -
<collection id="requestedBySelectorDc" class="com.company.sample.entity.ExtUser" view="_minimal">
<loader id="requestedBySelectorDl">
<query>
<![CDATA[select e from sec$User e where e.email = :userLogin]]>
</query>
</loader>
</collection>
I think you almost finished what you were trying to do. You forgot to set the parameter in the dataloader object. Take a look at this sample.
I don’t know your application usage scenario, but it seems a little strange to use a lookup field with only one possible value. If this “Requested By” should always be set to the logged user when a new item is created, I would suggest you to change this field to a readonly TextField and set this value when a new item is created.
I appreciate the suggestion for this screen. I tried the text field option seeing as for this screen I only need the currently logged in user. I know I must be over complicating it.
The controller gives me the following error
The XML file <textField id="RequestedBy" caption="Requested By" property="requestSubmitedBy" editable="false" />
Here is my Entity setup
When the drop down shows all names this is how the data is entered into the db.
By the text of the error, you don’t have a method called setRequestedBy(User) for the class SafeRequest. Also, according to the screenshot that you attached from the CUBA entity designer, the name of the field is the requestSubmitedBy, which means the method should consist of this name - setRequestSubmitedBy(User).
THANK YOU - The issue was partly with my onInitEntity code like you suggested @durygin. The issue also turned out to be my view. For the Extended Users Requested By i had the View in the viewset to user.browse. I changed it to Minimal and everything loaded as @peterson.br
Thank you both very much. I really appreciate your help.