RE: RE: Liferay Forms Submit

Manoj Kumar, modified 3 Years ago. New Member Posts: 10 Join Date: 11/26/21 Recent Posts

Hi All,

I have requirement, where have to call rest-api to save data on "submit" of "Liferay Form".

Any suggestion/solution regarding this will be helpful.

Thanks and regards:

Manoj Kumar

thumbnail
Fernando Fernandez, modified 3 Years ago. Expert Posts: 401 Join Date: 8/22/07 Recent Posts

Hi Manoj,

I suggest you create a model listener on Forms to detect when a form is saved and then you can proceed with whatever you need to do with the form data.

Something like this:

@Component(
    immediate = true, 
    service = ModelListener.class
)

public class FormProcessor extends 
             BaseModelListener<DDMFormInstanceRecord> {

    // Model listener - invoked when a form is recorded
	public void onAfterCreate(DDMFormInstanceRecord record) 
           throws ModelListenerException {
		try {
			long formPK = record.getPrimaryKey();
			if(record.getStatus()==WorkflowConstants.STATUS_APPROVED) {

    ...

 

HTH

Fernando

thumbnail
Manoj Kumar, modified 3 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts

Hi,

You can also try using Form Storage Adaptor, You can call your rest-api  from a custom form adapter along with json payload. Pls refer: 

https://help.liferay.com/hc/en-us/articles/360017889212-Forms-Storage-Adapters

thumbnail
Russell Bohl, modified 3 Years ago. Expert Posts: 308 Join Date: 2/13/13 Recent Posts

Since he;s tagged his post with "7.4", it's better to look at the Liferay Learn form storage adapter documentation: this article and this one.

Also Dave's blog on the topic.