Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-50478

Inconsistent behaviour retrieving the root field names of a child DDMStructure

    Details

      Description

      Successive calls to the method ddmStructure.getRootFieldNames() duplicate the parent field names in the result list.

      Steps to reproduce in Web Content.

      1. Go to Site Administration > Content: Web Content - Manage > Structures

      2. Create a parent structure: parent

      • Add two text fields: Parent field1, Parent field2

      3. Create a child structure: child1

      • Add two text fields: Child1 field1, Child1 field2

      4. Get the ID of these structures from Site Administration > Content: Web Content - Manage > Structures

      eg:
      ddmStructureIdParent = 11107;
      ddmStructureIdChild1 = 11109;

      5. Configure the next script with the previous IDs and run it from the Scripting Console selecting Groovy as language:

      import com.liferay.portlet.dynamicdatamapping.model.*;
      import com.liferay.portlet.dynamicdatamapping.service.*;
      
      long ddmStructureIdParent = 11206;
      long ddmStructureIdChild1 = 11208;
      
      DDMStructure parent = DDMStructureLocalServiceUtil.getStructure(ddmStructureIdParent);
      DDMStructure child1 = DDMStructureLocalServiceUtil.getStructure(ddmStructureIdChild1);
      
      out.println("");
      out.println("Parent");
      parent.getFieldsMap()
      for(String field: parent.getRootFieldNames()){
          out.println( "* " + field +":");
      }
      
      out.println("");
      out.println("Child1");
      child1.getFieldsMap();
      for(String field: child1.getRootFieldNames()){
          out.println( "* " + field +":");
      }
      

      Output:

      Parent
      * Parent_field1:
      * Parent_field2:
      * _fieldsDisplay:
      
      Child1
      * Child1_field1:
      * Child1_field2:
      * _fieldsDisplay:
      * Parent_field1:
      * Parent_field2:
      * _fieldsDisplay:
      

      6. Run the script again, unexpected output for the Child1

      Parent
      * Parent_field1:
      * Parent_field2:
      * _fieldsDisplay:
      
      Child1
      * Child1_field1:
      * Child1_field2:
      * _fieldsDisplay:
      * Parent_field1:
      * Parent_field2:
      * _fieldsDisplay:
      * Parent_field1:
      * Parent_field2:
      * _fieldsDisplay:
      

      The expected behaviour is to get the same result in successive calls.

      Note: Clearing cache from Control Panel > Server Administration reset the duplicated values.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  5 years, 50 weeks ago

                  Packages

                  Version Package
                  6.2.2 CE GA3
                  6.2.X EE