I plan to use Laserfiche forms in my web application. I have embedded the form on my page. How do i pull values entered in the form into my code behind?
I plan to use Laserfiche forms in my web application. I have embedded the form on my page. How do i pull values entered in the form into my code behind?
You can use a modified embed code for your form to allow the parent page and the embedded form to communicate (assuming both pages are within the same domain). See this page in the online help for more information.
Here's the example from that page:
<script type="text/javascript" src='FormsServerURL/Forms/js/forms-embed.js?v=9.1'></script> <script type="text/javascript"> var title = document.getElementById('title').innerHTML; var lf = new LaserficheForms.Form(document.getElementById('myform'), { bpid: 'ID', host: 'FormsServerURL/Forms', params: 'Topic_Name='+ title, onloadCallback: function () { var s = lf.getFrmDocument().getElementsByName('action'); if (s.length > 0) { s[0].onclick = function () { document.getElementById('myform').style.display = 'none'; }; } } }); </script>
You can specify field variables and their values using params, and you can use this onloadCallback function to interact with the form after it has loaded. In the above example, after the form loads, the script finds the action button and sets the iframe's display to "none" on the parent page when the action button is clicked.
Ok, let me try. How do you retreive the value of the form variables. What event gets fired when you hit the submit button in the form?
After the frame for the form page loads the event "onloadcallback" gets triggered. In our example code above what we create is a callback on submit button so when they click submit 'document.getElementById('myform').style.display = 'none';' gets run. Just run your code instead in that callback and you should access to form as well as your page elements. Just note the lf.getFrmDocument() is how you get the element on the forms page while document element is your page.
Ok, let me try. Thanks.
I have an alert statement inside the onloadcallback. It is not getting fired. What should be the value for "After submitting the form" in the business process that has the form?
Is it possible for you to send me a simple example please of the parent page? It always shows the thank you form for me. Thanks.
I am not able to get onloadcallback to trigger. This is my code. Can you please point out if i am doing anything wrong?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
</head>
<body>
<script type="text/javascript" src='http://v-dev-w7x64-26/Forms/js/forms-embed.js?v=9.1'></script><script type="text/javascript">lfembed = new LaserficheForms.Form(null /*element to place form in*/,{bpid: 'id', host:'http://v-dev-w7x64-26/Forms/js/forms-embed.js?v=9.1/Forms',
onloadCallback: function() {
alert('hi');
}
}).getFrm();</script>
</body>
</html>
onloadCallback is not getting fired when i hit the submit on the form. It always goes to thank you page
Can anyone please respond as to why onloadCallback is not getting fired when the form page loads? Thanks
You'll need to specify the appropriate business process ID and the Forms Server URL in your code. You can find these values on the Publish page for your process in the default embed code.
I did that. Is this a feature in Forms version 9.1?. Also, I want to call a javascript function when user hits submit. The javascript will call a server side function in asp.net. How do I do this?
The modified embed code is new to Forms 9.1.
Can you try to explain a little bit more?
You are working on an ASP.NET web app that will have a form integrated into it?
Are you unable to use a webhook to transfer data?
Yes. I have a asp.net application and trying to use laserfiche forms for the front end for some pages. When the user hits Submit, I have to access the database and access the message queue. Also, after that, i need to redirect the user to another form. i have not tried webhook. Is that the best way? Thanks a lot for prompt response.
I am confused about having to route the user to another form, that's a built in Forms functionality.
Since you are using ASP.NET for a web app, you may want to make it reference-capable and have the webhook point to the webapp. This is likely the easiest way to transfer the information you desire without having to query the DB's or create a custom bit of code that will grab the form submission before LF Forms does.
This would also ensure that moving forward, you do not have any incompatibilities as you are using built in LF Forms functionality to accomplish a task.
Ok. Do you have any examples? Also how do i call third party api's in this approach once the user hits submit?