Hello everyone.
So i'm working on a form for a client and I've been provided some scripts that generate the form.
The form appears on the page nicely and everything appears to work but the submissions.
My formSubmit event looks like this and it goes through...
MsCrmMkt.MsCrmFormLoader.on('formSubmit', (e) => { e.preventDefault(); window.formSubmitResult = MsCrmMkt.MsCrmFormLoader.sendFormCaptureToCrm(el.querySelector('form')); formSuccess(); console.log("MsCrmMkt.MsCrmFormLoader.on('formSubmit') called."); console.log('result: ', window.formSubmitResult); });
"Error: form was not recognized as valid for form capturing. at FormCaptureSendingQueue.sendingCallback (https://mktdplp102cdn.azureedge.net/public/latest/js/form-loader.js?v=1.71.2017.0:4:290023) at https://mktdplp102cdn.azureedge.net/public/latest/js/form-loader.js?v=1.71.2017.0:4:36078 at M (https://mktdplp102cdn.azureedge.net/public/latest/js/form-loader.js?v=1.71.2017.0:4:2680) at new t (https://mktdplp102cdn.azureedge.net/public/latest/js/form-loader.js?v=1.71.2017.0:4:5913) at FormCaptureSendingQueue.enqueue (https://mktdplp102cdn.azureedge.net/public/latest/js/form-loader.js?v=1.71.2017.0:4:36012) at Function.FormLoaderInternal.sendFormCaptureToCrm (https://mktdplp102cdn.azureedge.net/public/latest/js/form-loader.js?v=1.71.2017.0:4:38959) at http://ppe.wpup.lt/wp-content/themes/ppe/assets/js/app.js?ver=1.0.1:30396:58 at Function.FormLoaderInternal.triggerCallbacks (https://mktdplp102cdn.azureedge.net/public/latest/js/form-loader.js?v=1.71.2017.0:4:37688) at Function.FormLoaderInternal.trigger (https://mktdplp102cdn.azureedge.net/public/latest/js/form-loader.js?v=1.71.2017.0:4:37805) at FormLoaderInternal.trigger (https://mktdplp102cdn.azureedge.net/public/latest/js/form-loader.js?v=1.71.2017.0:4:37434)"
It's looking for a `data-form-page-id` attribute on the `form` element, not sure why, but its not there. So you can manually add it before it submits;
<script type="text/javascript">
let formPageId;
MsCrmMkt.MsCrmFormLoader.on("formLoad", function(e) {
formPageId = e.getFormPageId();
});
document.querySelector('#button').addEventListener('click', function() {
const form = document.querySelector('form');
form.setAttribute("data-form-page-id", formPageId);
MsCrmMkt.MsCrmFormLoader.sendFormCaptureToCrm(form).then(function() {
console.log('submitted');
}, function(err) {
console.log(err);
});
});
</script>
I think possibly you missed the key point from what Nya replied: you can't use "formSubmit". You CAN use "afterFormSubmit".
I'm having a similar issue with the same error - I don't suppose you've found a solution have you? :)
Hey Nya, thank you for your answer. My problem is that however I try to submit it returns the same error.
Even if I try submitting it from the console like that:
MsCrmMkt.MsCrmFormLoader.sendFormCaptureToCrm(el.querySelector('form'));
The outcome is always the same: "Error: form was not recognized as valid for form capturing.".
Is there a way to know what makes the form unrecognisable for capturing?
Hi,
Please refer to the following section:
Extend marketing forms using code (Dynamics 365 Marketing Developer Guide) | Microsoft Docs
It shows that the formSubmit event will not be triggered for captured forms.
If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.
Best Regards,
Nya
André Arnaud de Cal...
292,111
Super User 2025 Season 1
Martin Dráb
230,934
Most Valuable Professional
nmaenpaa
101,156