You are viewing limited content. For full access, please sign in.

Question

Question

modern designer submit event on temporary button click

asked on October 17, 2023

Hello Team,

I have created custom HTML button to call some external API within Laserfiche modern form designer as per below link.

https://answers.laserfiche.com/questions/210704/Clickable-custom-button-to-showhide-fields-in-Modern-Forms-designer

As soon as any response will coming from API, we needs to call submit button event. This is possible (check attached code.txt) in classic designer but how to achieve same from modern JavaScript custom code.

1. How to call submit event within custom HTML button click .
2. How to validate forms before call submit event from custom HTML button.

This is my entire flow
>>Custom button click event>> Forms validation completed>> API call>>Submit event>>Forms saved in repository.

My Overall objective is

 

We need to restrict (wait) submission until an API response comes, which is our overall objective.

Currently, we are using fetch for API requests and responses, as per the below link.

https://dmitripavlutin.com/javascript-fetch-async-await/

As soon as we receive any response from the API, we need to wait for form submission.

Currently, when we click on the submit button, the LF form is directly submitted without waiting for an API response, but we need to save it based on the "success" response within the API call. And that's why we are calling fetch API from custom button and once response will come based on that we need to call submit event.


Thanks,
Pratik

0 0

Replies

replied on October 17, 2023

I don't think you are going to be able to programmatically call the Submit button from Javascript in the Modern Designer.  That isn't something currently possible in the LFForm object.  The Javascript in the Modern Desinger runs within a sandboxed iFrame and doesn't have direct access to the Fields/Form/Window components, only the elements included in the LFForm object.

But you should be able to use Field Rules to hide the submit button until a field is populated with the success response, and have the Javascript populate that response into the contents of that field.  Then use Field Rules to always hide that field from the user (but selecting the option to still save its value).

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.