Affects Version/s: 6.2.X EE, 7.0.X EE, Master
Component/s: Dynamic Data Lists
The DDLRecordLocalServiceUtil.addRecord(long, long, long, int displayIndex, Map<String, Serializable>, ServiceContext) method allows the user to pass in a map with values for each field in the DDLRecordSet. The Fields variable is then constructed from this Map.
However, there is no way to pass in multiple values for a repeatable field. If you put an array or a Collection of values into the Map for that field name, the addRecord method interprets the entire Collection or array as a single String value. So, only one value is added for that field, instead of however many values were in the array.
Note that this method is deprecated in master and ee-7.0.x. However, the bug still exists regardless, so we will fix it in there. This method is by far the most user-friendly one for programmatically creating DDLRecords, as it doesn't require the user to go through the convoluted process of creating a Fields object or a DDMFormFieldValues object.
Note also that the user will be required to add in the _fieldsDisplay value to the Map that they pass in in order for the method to work properly with repeatable fields. If the _fieldsDisplay value is not passed in, there would be scenarios under which it would be impossible to know the order in which repeatable elements should be listed in the DDLRecord. For this reason, it should be required that the user construct and pass in the _fieldsDisplay. If the user does not do this, each repeatable element will only show up once, regardless of the sizes of the Lists or arrays that were passed in.
Steps to Reproduce
- Start Liferay and sign in as the admin user.
- Go to Left-Hand Navigation menu > Liferay > Content > Dynamic Data Lists > Add Button
- Give your List a name.
- For Data Definition, click Select and then use the Add Button to add a new Data Definition.
- Give your Data Definition a name.
- For your fields, add a single non-repeatable Text field, and a single repeatable Boolean field nested inside the Text field.
- Note the Name of your text field and your Boolean field (this will be important later on).
- Save your Data Definition and select it for use in your List.
- Save your List
- Find the following Ids and make a note of them:
- userId of Test Test: Left-Hand Navigation menu > Test > My Account > Account Settings > User ID
- groupId of the Liferay Site: Left-Hand Navigation menu > Liferay > Configuration > Site Settings > Site ID
- recordSetId of the DDL you created: Left-Hand Navigation menu > Liferay > Content > Dynamic Data Lists > ID
- Navigate to Left-Hand Navigation menu > Control Panel > Configuration > Server Administration > Script.
- Change the Language to Groovy.
- Download the attached callAddRecord.groovy file corresponding to the version of Liferay you are testing on, and paste the contents into the Script box.
- Change these lines to the values you noted in step 7:
- Change these lines to the values you noted in step 10:
- Click Execute.
- Navigate to Left-Hand Navigation menu > Liferay > Content > Dynamic Data Lists > Click the DDL you created > Click on the new Record that the script inserted.
Expected Result: The Booleans inserted would be "Yes" and then "No" as per this line of code:
Actual Result: The Booleans inserted are "No" and "No".
master? Yes, issue reproduced in master, although the method is deprecated in master (4c0c1a6088cc57dace55ce083e6b0eeda4582dfa)
ee-7.0.x? Yes, issue reproduced in ee-7.0.x, although the method is deprecated in ee-7.0.x (1d202adbbb6d77698949a5f6e2e365025de32f03)
ee-6.2.x? Yes, issue reproduced in ee-6.2.x (3739510bc58420fedf0fdad7ee8003bbe91a0fc1)