Workaround for deprecated Liferay "Forms" headless API

Issue

Environment

  • Version: Liferay DXP 7.4 Quarterly Releases

Resolution

  •  You can use both the Java API or the JSONWS API.
    See the following examples:
     
    You can access the form values (with Java API) as follows:
    List<DDMFormInstanceRecord> ddmFormInstanceRecords = DDMFormInstanceRecordServiceUtil.getFormInstanceRecords(formId); 

    for (DDMFormInstanceRecord ddmFormInstanceRecord : ddmFormInstanceRecords) {
    DDMFormValues ddmFormValues = ddmFormInstanceRecord.getDDMFormValues();

    for(DDMFormFieldValue ddmFormFieldValue : ddmFormValues.getDDMFormFieldValues()) {
    String name = ddmFormFieldValue.getName();
    Value value = ddmFormFieldValue.getValue();

    for(Locale locale : value.getAvailableLocales()) {
    String valueString = value.getString(locale);
    }
    }
    }
    You can also access the ddmFormInstanceRecords (with JSONWS API) as follows:
    curl http://localhost:8080/api/jsonws/ddm.ddmforminstancerecord/get-form-instance-records \
    -d ddmFormInstanceId={formId}
    Note, that here, the result does not provide the field values.

 

Was this article helpful?
0 out of 1 found this helpful