Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Form Submission

(0) ShareShare
ReportReport
Posted on by 205

Hello, I like to receive submission from form capture only if the Checkbox is checked. 

here is the code I created: 

<script src="">mktdplp102cdn.azureedge.net/.../form-loader.js <div class="d365-mkt-config" style="display:none" data-ignore-prevent-default="true" data-no-submit="true" data-website-id="0op_lGiqvzb8EhCnvxxKF8M5EgXDTTwy2kUINDDRTaw" data-hostname="d83e4f8d78034cc28d062fc3641101bf.svc.dynamics.com"> </div>
<script>
var form = document.querySelector('form');
form.onsubmit = function() {
 
var formInputCheckboxByID = document.getElementById('25254a33-c81d-4fc9-a9d2-5b9aaa6839a4');
var formInputCheckboxByClassName = document.querySelector('.ikvindhetprimawanneervattenfallmijngegevensbewaartommijperemailinteressanteaanbiedingentesturenmbtlaadoplossingenvoorelektrischvervoergeenzorgenwehoudenhetbescheiden input[type=checkbox]'); 
 
if(formInputCheckboxByID.checked || formInputCheckboxByClassName.checked) {
MsCrmMkt.MsCrmFormLoader.sendFormCaptureToCrm(form);
}
 
}
</script>
but now, I am not receiving any submission. 
can you help me, please? 
Thank you , 
Elly
  • RE: Form Submission

    Hola, tengo un inconveniente. Tengo capturados varios formularios de una web externa, es decir a través de un script que le solicito al desarrollador web que inserte en su código. Lo que sucede es que cada vez que alguien olvida completar algun campo obligatorio se envía ese formulario igual aunque falten campos. Que debería pedirle al desarrollador web que agregue el script para que solo ingresen los envíos de formulario correctamente completados??

    Gracias! ojala puedas ayudarme!

  • Lav Shah Profile Picture
    Lav Shah 5 on at
    RE: Form Submission

    Hello Clofly Mao ,

    I've the same issue, in my use-case we are not using any conditional submission, but I want to add some validations & want to add redirecitons after form is submitted.

    I'm checking all the events given here: docs.microsoft.com/.../marketing-form-client-side-extensibility

    I added them in my code as below, but. none of them is logging anything in console.

    Code is as below:

    <form>
    <label class="form__label" for="firstName">First Name</label>
    <input
    type="text"
    id="firstName"
    name="firstName"
    placeholder="Enter first name"
    />
    //...more inputs
    </form>
    <div
    class="d365-mkt-config"
    style="display: none"
    data-website-id="<data-website-id>"
    data-hostname="<some-id>.svc.dynamics.com"
    ></div>

    <script src="">mktdplp102cdn.azureedge.net/.../script>
    <script>
    // formLoad
    MsCrmMkt.MsCrmFormLoader.on("formLoad", function () {
    console.log("formLoad")
    });

    //formRender
    MsCrmMkt.MsCrmFormLoader.on("formRender", function () {
    console.log('formRender');
    });

    // afterFormRender
    MsCrmMkt.MsCrmFormLoader
    .on("afterFormRender", function(event) {
    console.log('afterFormRender');
    });


    // afterFormLoad
    MsCrmMkt.MsCrmFormLoader
    .on("afterFormLoad", function(event) {
    console.log('afterFormRender');
    })

    //formSubmit
    MsCrmMkt.MsCrmFormLoader
    .on("formSubmit", function(event) {
    console.log('thanks for submit');
    });

    // afterFormSubmit
    MsCrmMkt.MsCrmFormLoader
    .on("afterFormSubmit", function(event) {
    console.log("afterFormSubmit")
    })
    </script>

    Can you help us to get this resolved?

  • Elly-Farokhi Profile Picture
    Elly-Farokhi 205 on at
    RE: Form Submission

    Thank you for the response cofly. :)

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Form Submission

    Hi Elly,

    If we have a custom checkbox field: Email allow and map it to "Do not email" form field,

    when the field is ticked and form is submitted, Bulk Email field of the new contact will be set to "Do Not Allow".

    That because for the OOB Bulk Email field, it uses true/checked to stand for "Do Not Allow", false/unchecked to stand for "Allow".

    Therefore, contact who ticked the custom field will be excluded from marketing email.

    Regards,

    Clofly

  • Elly-Farokhi Profile Picture
    Elly-Farokhi 205 on at
    RE: Form Submission

    Hello Cofy,

    I tried this technique and realized that the website logic is not allowing the submission after form submitted.

    Thats why I linked the field to Send marketing email checklist.

    Do you know if this field act like Do not bulk email as well and exclude people from marketing email automatically if it is not ticked?

    Many Thanks,

    Elly

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Form Submission

    Hi Elly,

    Here are my suggestions:

    1. Only keep data-no-submit="true" attribute, remove data-ignore-prevent-default="true" attribute, because we only want to perform sendFormCaptureToCrm function by ourselves.

    2. Check whether you have gotten checkbox elements correctly.

    (Because you are using form capture, therefore, you can set a simple id name for the checkbox, e.g: id="email-allowed", in my form, I get all checkboxes with getElementById method)

    3. Due to you are using document.querySelector('form') method, hence you could check whether there is only one form on page.

    Code of my form capture:

    Script:

    (add alert function to monitor whether there is anything incorrect.)

    function submitForm() {
    
      var emailAllowed = document.getElementById("allow-email");
      if (emailAllowed.checked) {
        var form = document.getElementById("contactForm");
        alert("Thank you for submission.");
        MsCrmMkt.MsCrmFormLoader.sendFormCaptureToCrm(form);
      } else {
        alert("We can't send email to your if you don't allow email.");
      }
      
    }

    Form element:

    <form id="contactForm" onsubmit="submitForm()">

    </form>

    Page:

    pastedimage1600760096540v1.png

    Regards,

    Clofly

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans