Forms Data provider the localhost headless-admin-user access

thumbnail
Jamie Sammons, modified 2 Years ago. New Member Posts: 13 Join Date: 1/16/19 Recent Posts

Steps to reproduce

Use  liferay-ce-portal-7.4.3.79-ga79

  1. Allow Access Local Network in System Settings > Data Provider

  2. Add  System Settings ->  API Authentication -> Basic Auth Header :  /api/,/xmlrpc,/o/*

  3. System Settings ->  API Authentication -> Portal Sessions : /api/json*,/api/jsonws*,/c/portal/json_service*,/o/*

  4. Test http://localhost:8080/o/headless-admin-user/v1.0/my-user-account is working,

  5. Create a new data provider named my-user-account

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

    2. Output name: path $..name and type: Text, Label; name

  6. Create a new form Form

    1. add a field Name of type Text

    2. in the Autocomplete select From Data Provider

    3. Choose a Data Provider:my-user-account and Choose an Output Parameter: name

  7. Save the form

  8. Publish the form

  9. Go to the Form URL

Expected behavior

A Form will be prefilled by : Test Test, as it is in the json field: <name>Test Test</name>

Current behavior

2023-06-09 14:24:39.719 WARN  [hystrix-DDMDataProviderInvokeCommandGroup-1][DDMRESTDataProvider:121] The data provider was not able to connect to the web service. Unable to transmit request to localhost

Nothig is prefilled.

 

PS.: I have created by mistake LPS-187170 as a copy of another similar issue. There are prefiled wrong labes and branches, I could not change.

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

Hi Petr, I can see a couple issues with this off the bat:

1. The JsonPath expressions $..name will return any element called name, including for the user's role names, site names, etc.. So you're actually getting a list from the data provider they way you have it configured. You can test this by pasting the response from the API explorer into the JsonPath evaluator here: https://jsonpath.com/. Using the expression $.name returns just the user's name.

2. Autocomplete is meant for use with a List return type. The user begins typing in the text field and a filtered list of options is shown as a drop-down. What you may actually want is to use an Autofill rule. See Using the Autofill Rule

Editing to add: I'm not sure it will actually work even if you try my suggestion. I know in the past there have been issues around autofilling using the form user's own user data, but I think your approach needs to be improved to find out if there's really a bug.