Search code examples
javaliferayliferay-7

How to get liferay form name through code in java


I am writing the code to fetch liferay forms through java but I am unable to do so. I am using recordset to do it but it is only fetching DDL recordset not forms.

public List<DDLRecordSet> getRecordSets()  {
        
        long groupId = themeDisplay.getScopeGroupId();
        System.out.println("groupId:::"+groupId);
        long liveGroupId = themeDisplay.getScopeGroup().getLiveGroupId();
        
        System.out.println("LiveGroupID::"+ liveGroupId);
        

        List<DDLRecordSet> results = DDLRecordSetLocalServiceUtil.getRecordSets(themeDisplay.getScopeGroupId());
        if (liveGroupId != 0) {
            results.addAll(DDLRecordSetLocalServiceUtil.getRecordSets(groupId));
        }
        System.out.println("Result::"+ results);
             return result;

}

The output is shown only for DDL recordset not of form recordset.

Output= Result::[{mvccVersion=0, uuid=7ca2308a-29f0-b344-8eeb-13eda08fe745, recordSetId=46003, groupId=20124, companyId=20101, userId=35402, userName=Test1 Test1, versionUserId=0, versionUserName=, createDate=Fri Jun 11 05:06:35 GMT 2021, modifiedDate=Fri Jun 11 05:06:35 GMT 2021, DDMStructureId=34991, recordSetKey=46002, version=1.0, name=, description=, minDisplayRows=10, scope=0, settings=, lastPublishDate=null}]

Please let me know where am I wrong.


Solution

  • To fetch all the created forms of a group/site, you can fetch the DDMFormInstances via DDMFormInstanceLocalServiceUtil.getFormInstances(groupId) (or better to use osgi references instead). For me, it is not clear what is required in your scenario (form, form-fields, form-data).

    If you want the submitted data (depending on your handler this might differ), you can usually look for the corresponding DDMFormInstanceRecord and check the storageId which might be contentId of DDMContent which holds your data (usually in json).