Issue
-
I am trying to fill a text field using the DDMRestDataProvider and the Autofill Rule. I was inspired by the following article:
https://learn.liferay.com/w/dxp/process-automation/forms/form-rules/using-the-autofill-rule
-
I set up a DDMRestDataProvider as follows:
Read Access for Guest allowed
URL: https://restcountries.com/v3.1/name/deutschland
Outputs:
Path: $..name.common
Type: Text field
Label: "Name Common"
Environment
- Liferay DXP 7.4
Resolution
- Currently the returned result is in a JSONArray, due to the usage of the
indefinitepath:$..name.common. - That is the reason why the text field cannot be autofilled with the value, since the return is not a single value.
- If you will use a path that is a
definitepath instead of anindefinitepath, it should return a single value. -
JsonPath library's documentation
A path is
indefiniteif it contains:-
..- a deep scan operator -
?(<expression>)- an expression -
[<number>, <number> (, <number>)]- multiple array indexes
Indefinitepaths always returns a list (as represented by current JsonProvider). -
-
Recommended solution: changing the path to
$.[0].name.commonwould change it to adefinitepath and the expectation would be that a single value is returned. -
Note: this is a proof of concept and ultimately it is up to you to decide on how to configure a Data Provider for your particular use-case.
- Additionally, you will also need to set View permission for the Guest user on the Data provider, in order to get the text field autofilled for the guests.