Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Error: form was not recognized as valid for form capturing.

Posted on by 5

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);
});


 but window.formSubmitResult outputs:

"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)"


I've tried adding and removing various attributes i've found in the documentation like data-no-submit="true" and data-ignore-prevent-default="true" but it doesn't seem to work.

According to client the visits are getting tracked but there are no submissions.

The form can be accessed here: http://ppe.wpup.lt/contact/ , you can fill it with method window.fillForm()

Anybody can help me with this one? 

  • Suggested answer
    nickmcelligott Profile Picture
    nickmcelligott 5 on at
    RE: Error: form was not recognized as valid for form capturing.

    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>
  • AriaConsulting Profile Picture
    AriaConsulting 2,655 on at
    RE: Error: form was not recognized as valid for form capturing.

    I think possibly you missed the key point from what Nya replied: you can't use "formSubmit".  You CAN use "afterFormSubmit".

  • thecharwest Profile Picture
    thecharwest 215 on at
    RE: Error: form was not recognized as valid for form capturing.

    I'm having a similar issue with the same error - I don't suppose you've found a solution have you? :)

  • donnervetter Profile Picture
    donnervetter 5 on at
    RE: Error: form was not recognized as valid for form capturing.

    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?

  • Suggested answer
    Nya Profile Picture
    Nya 29,056 on at
    RE: Error: form was not recognized as valid for form 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.

     pastedimage1625814694545v1.png

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans