Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: RE: Liferay Forms Submit
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
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
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
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.
Powered by Liferay™