RE: RE: LIferay 7.4 Data provider only returning result for Default User.

Jamie Sammons, modified 2 Years ago. New Member Posts: 2 Join Date: 11/2/22 Recent Posts

Hi,

I am trying to use data provider for a form in Liferay 7.4, where the Name field will be autofilled by the name of current logged in user. I have tried and tested the data providers with these to API

http://localhost:8080/o/headless-admin-user/v1.0/my-user-account

http://localhost:8080/api/jsonws/user/get-current-user

In the data provider creation page USER Name and Password field were left blank as we need use the data provider for various logged in users.
 
Did get some error related to permission issue.
So... 1) Granted view permission for users for the data provider.
         2) Created service policy with enable and default  for com.liferay.portal.kernel.service.UserService.getCurrentUser.
 
 
Now I am able to get the field prepopulated through DATA Provider but it is only populating with information from the Default account.
I have tested with adding p_auth as a parameter too still same result.
If I add an account User Name and Password in the Data Provider, form is being prepoluated with that user's information not the current logged in user's.
 
Just wondering if anyone has comme across the issue and what could be the possible solution? Thanks for reading.
 
 
 
 
 
 
 
 
 
thumbnail
Jamie Sammons, modified 2 Years ago. Expert Posts: 308 Join Date: 2/13/13 Recent Posts

Hi Minhaj, you've run into a known limitation with the REST Data Provider. One option is to develop a custom data provider that's a bit smarter. I think this one is actually doing what you want.

The recommended approach in 7.4 is likely to create an object definition with the fields, then use fragments to set up the form container and fields. I think there's a new Form Container fragment that can help.

Jamie Sammons, modified 2 Years ago. New Member Posts: 2 Join Date: 11/2/22 Recent Posts

Thanks a lot for the reply. I will give it a try. Have a good one.

Jamie Sammons, modified 2 Years ago. New Member Posts: 2 Join Date: 12/1/22 Recent Posts

hello, i tried to install this module but it doesnt work. the data provider is visible and configurable but the form does not fill

thumbnail
Jamie Sammons, modified 2 Years ago. Expert Posts: 308 Join Date: 2/13/13 Recent Posts

Hi Gregory, I didn't write the data provider and likely can't help troubleshoot it. I recommend taking the data provider from there, looking at the code to understand what it's trying to do, then, if you can't figure out why it's not working, write a separate and detailed post about what you've tried and what's going wrong.