Loading

Account Engagement Prospect Activity Shows Multiple Form Submissions

Дата публикации: Sep 30, 2025
Описание
You might have seen multiple form submissions on a prospect's activities, which don't make much sense, as they are only minutes or even seconds apart. It is not possible to control how many submissions are tracked depending on how many times the button is clicked, so this is very likely to be caused by a prospect clicking on the submit button more than once.
Решение

There are a couple of options you can add to your custom code. Please note that as this is a custom setup, this is something that the Account Engagement Support Team cannot help to implement or troubleshoot.


1. Disabling the submit button

By default, you can click the submit button as many times as you want. In practice this can cause a form to be submitted, or some other event triggered, more than once.
 
The trick is to use JavaScript to set the disabled property of the button to true
 
For a simple form, with no associated JavaScripts, you can use:
<form method="POST" action="..." onsubmit="myButton.disabled = true; return true;"> ... <input type="submit" name="myButton" value="Submit"> </form>
 
 

2. Changing the button's text

Rather than simply disabling the button, you can also change the text so that people don't get confused. For example, it first disables the button and then changes the label from "Submit" to "Please wait...". 

The code executed when the form is submitted includes the following:
<script type="text/javascript"> function checkForm(form) // Submit button clicked { // // check form input values // form.myButton.disabled = true; form.myButton.value = "Please wait..."; return true; } function resetForm(form) // Reset button clicked { form.myButton.disabled = false; form.myButton.value = "Submit"; } </script>
 
While the HTML for the form itself looks something like:
<form method="POST" action="..." onsubmit="return checkForm(this);">
...
<input type="submit" name="myButton" value="Submit">
<input type="button" value="Reset Button" onclick="resetForm(this.form);">
</form>


3. Using external JavaScript

We're not changing any of the functionalities here, just preparing the JavaScript so it can be moved to an external JavaScript file, and doing away with the necessity for global variables.
First, we strip out any event handlers from the HTML, and assign id values to the elements needing event listeners.
<form id="test_form" method="POST" action="..."> <p>First Name: <input type="text" size="32" required name="firstname"></p> <p>Last Name: <input type="text" size="32" required name="lastname"></p> <p><input type="submit" name="submit_button"> <input id="reset_button" type="button" value="Reset Button"></p> </form>
 
Note that there is no need to assign an id to all the form elements. Only those with event handlers, and even then we could make do with only the FORM having an id if we wanted.
 
The next step is to define and assign our event handling functions. The main difference here is that each function receives a variable e representing the event, from which e.target can be used to identify which element was targeted.
 
And in the form validation script instead of return false; we use e.preventDefault(); which prevents the form from submitting, and then return; to exit the script. There is no need for a return true; at the end.
 
Finally, we wrap all the code in a DOMContentLoaded function allowing us to create variables without them becoming global. This also delays the script initialization until the HTML is fully loaded.
<script type="text/javascript"> window.addEventListener("DOMContentLoaded", function(e) { var form_being_submitted = false; var checkForm = function(e) { var form = e.target; if(form_being_submitted) { alert("The form is being submitted, please wait a moment..."); form.submit_button.disabled = true; e.preventDefault(); return; } if(form.firstname.value == "") { alert("Please enter your First Name"); form.firstname.focus(); e.preventDefault(); return; } if(form.lastname.value == "") { alert("Please enter your Last Name"); form.lastname.focus(); e.preventDefault(); return; } form.submit_button.value = "Submitting form..."; form_being_submitted = true; }; var resetForm = function(e) { var form = e.target.form; form.submit_button.disabled = false; form.submit_button.value = "Submit"; form_being_submitted = false; }; document.getElementById("test_form").addEventListener("submit", checkForm, false); document.getElementById("reset_button").addEventListener("click", resetForm, false); }, false); </script>
 
The JavaScript can now be included either inline on the page, or in a separate JavaScript file referenced by the SCRIPT tag, and it will not interfere with any other scripts on the page because the event listener creates a closure and the contained functions are all defined as local variables.
 
If you plan to include the JavaScript inline, then instead of using a DOMContentLoaded event handler you can use an IIFE (Immediately Invokable Function Expression) as follows:
(function() { var form_being_submitted = false; var checkForm = function(e) { ... }; var resetForm = function(e) { ... }; document.getElementById("test_form").addEventListener("submit", checkForm, false); document.getElementById("reset_button").addEventListener("click", resetForm, false); })();
 
In this case, the code needs to be placed inline anywhere after the FORM - usually at the bottom of the page before the closing BODY tag. It can't be made external or it might execute before the DOM is ready for the event handlers to be assigned.
Номер статьи базы знаний

000382956

 
Загрузка
Salesforce Help | Article