Jump to content

Submit One Form To 2 Different Tables?


Recommended Posts

Sorry for all the questions, I do search/read the topics and forum for help before posting!  :)

 

How would I use a single form submission to enter data into two different tables at the same time? 

 

For example, user adds a customer of his, which then creates an entry in the "Clients" table (because it is new), and also creates an entry in the"Sales_Coverage" table to create an association between him (Person) and that Client.

 

It would be impractical to have a user enter this info into two different forms.

 

Thank you in advance,

 

Chris

Link to comment
Share on other sites

You can create another DataPage based on the other table and have it as the destination after submission. Check to receive the parameters that need to be passed to this page and received them on the new page. In the second page you can have auto submit button upon page load by having this code in an HTML Block at the end of the list elements:

<script>
function f_submit() {
document.getElementById("caspioform").submit();
}
document.addEventListener('DataPageReady',f_submit);
</script>

After adding data to the first page, user will be redirected to the next page which will be auto submitted and user will see the successful submission message. If you would like you can hide the submit button and also the fields on the page.

 

To hide the submit button, create a copy of the style. Check Show Advanced Options (CSS Source), navigate to setting screens and under Firms/Details >> Buttons switch to Source tab and add display:none; to .cbSubmitButton

To hide elements use table tags: http://howto.caspio.com/tech-tips-and-articles/common-customizations/how-to-hide-fields-in-datapages/

Link to comment
Share on other sites

  • 9 months later...

Hello,

 

How do I pass an autonumber field from a submit form to another submit form? The autonumber is not listed as a field on the 1st submit form, so I cannot find where I can enable pass and receive of this field. I need to split a database into 2, due to 255+ fields and need to link the 2nd table to the 1st via the same autonumber. I am able to pass values via the virtual field to the 2nd submit form (hidden) using the script above but need to get the autonumber to bridge as well. Doesnt the autonumber generate at the time of submit, and if so how do I get it to pass to the 2nd submit form?

Link to comment
Share on other sites

In regards to the message above, I found the checkbox where you can select to pass the autonumber, and have enabled receive of this autonumber on the 2nd submit form, however I am still unable to get the autonumber to bridge over. On the second table, I have set the field to number type, whereas the first table has it set as an autonumber field.

Link to comment
Share on other sites

  • 3 years later...

With regards to Chris and May,  because of recent releases and the asynchronous enhancements I was receiving an error message form the bridge about the "onload" event so I think this should suffice:

<script type="text/javascript">
function f_submit() {
document.getElementById("caspioform").submit();
}
document.addEventListener('DataPageReady',f_submit);
</script>

Ref:

https://howto.caspio.com/deployment/?_ga=2.55701288.248583459.1515247308-2040463417.1503146327

Link to comment
Share on other sites

  • 2 weeks later...

There all, according to https://howto.caspio.com/deployment/,  when switching from legacy deployment method to asynchronous method, existing JavaScript customization code in your DataPages must be updated if it contains any of the following:

If your script contains onload event similar to the one here:

<script type="text/javascript">
window.onload = function() {
// do something
});
</script>

The onload event should be replaced with Caspio built-in event as shown below:

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
// do something
       
});
</script>

You can also use event.detail.appKey or event.detail.uniqueSuffix to specify which DataPage’s loading event to execute your functions using the example below:

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
       if (event.detail.appKey == 'MY_DATAPAGE _APPKEY') {
              //do something 
       } else if (event.detail.appKey == 'MY_WEB_FORM_APPKEY') {
              //do something
    }
});
</script>

Therefore I have updated the code above

Link to comment
Share on other sites

  • 1 year later...

Hello everyone,

I just wanted to share something, I've tried following the recommendations in this post and initially  use the code below to auto submit my second DataPage once I successfully received the value from my first DataPage

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {

  document.getElementById("caspioform").submit();
       
});
</script>

But I've encountered some issue, the second DataPage will keep on submitting records until I close the tab. As a result, my table will be flooded with blank records that only contains the primary key of my Table.

What I did to fix that, is the code below and attached it to an HTML block and the issue has been resolved. 

<script type="text/javascript">
  if(document.getElementById("caspioform")) {
  document.getElementById("caspioform").style.display = 'none';
  setTimeout('document.forms["caspioform"].submit()',1000); } 
</script>


Regards,

TsiBiRu

Link to comment
Share on other sites

  • 2 months later...
On 3/7/2019 at 3:31 PM, TsiBiRu said:

Hello everyone,

I just wanted to share something, I've tried following the recommendations in this post and initially  use the code below to auto submit my second DataPage once I successfully received the value from my first DataPage


<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {

  document.getElementById("caspioform").submit();
       
});
</script>

But I've encountered some issue, the second DataPage will keep on submitting records until I close the tab. As a result, my table will be flooded with blank records that only contains the primary key of my Table.

What I did to fix that, is the code below and attached it to an HTML block and the issue has been resolved. 


<script type="text/javascript">
  if(document.getElementById("caspioform")) {
  document.getElementById("caspioform").style.display = 'none';
  setTimeout('document.forms["caspioform"].submit()',1000); } 
</script>


Regards,

TsiBiRu

Hey @TsiBiRu, with this fix, are you just closing the form 1 second after the submit button is clicked?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...