Skip to main content

Notifications

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

Marketing Form Date Field without Sundays

Posted on by Microsoft Employee

Hello,

I have a marketing form for a callback service in which the user can choose with a date field when he would like to be called.
Unfortunately, the fields for Sundays are also available, but shouldn't be here in this case.
Can someone please tell me how I can hide or gray out Sundays here?
Many thanks.

Best regards,

Ferdinand Ganter

pastedimage1604925590306v2.png

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Marketing Form Date Field without Sundays

    Hi Clofly,

    My Script is already in Marketing page.

    I think I should debug it well.

    Thank you for the help & quick response.  :)

    Regards,

    Vivek

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Marketing Form Date Field without Sundays

    Hi Vivek,

    Script inside source code of marketing form will always be ignored, it is by design.

    Please put your code to marketing page instead.

    Regards,

    Clofly

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Marketing Form Date Field without Sundays

    Yes field ID is correct. I can also confirm it from pre-suggestions I get while entering field values.

    It works for me when my script is like this & my field is outside the form(that is created in Marketing Page):

     <script>

     $( function() {

       $( "#ba834639-e227-eb11-a813-0022480a006f" ).datepicker({

               beforeShowDay: function (date) {

                   var day = date.getDay();

                   return [(day != 0), ''];

               }

           });

    });

     </script>

    but it does not work when my script is like below for a field inside the marketing form:

    <script>

       MsCrmMkt.MsCrmFormLoader.on('afterFormRender', function (event) {

           $("#ba834639-e227-eb11-a813-0022480a006f").datepicker({

               beforeShowDay: function (date) {

                   var day = date.getDay();

                   return [(day != 0), ''];

               }

           });

       })

    </script>

    And my field on a form is : 

     <div class="lp-form-field" data-required-field="false"><label for="ba834639-e227-eb11-a813-0022480a006f" class="lp-ellipsis" title="">Date String</label><input id="ba834639-e227-eb11-a813-0022480a006f" name="ba834639-e227-eb11-a813-0022480a006f" type="text" placeholder="" class="lp-form-fieldInput" title="" style="width: 100%; box-sizing: border-box;"></div>

    Thank you

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Marketing Form Date Field without Sundays

    Hi Vivek,

    Check whether id of the input field you want to capture is right.

    pastedimage1605520871239v1.png

    Regards,

    Clofly

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Marketing Form Date Field without Sundays

    Hi Clofly,

    For me I am unable to inject a datepicker for a field in a form.

    It is only working for fields outside the form. Have you implemented this before?

    Please help

    Thank you

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Marketing Form Date Field without Sundays

    Hi Clofly,

    thank you for your quick and detailed answer. That helped me alot.

    Thank you.

    Regards,

    Ferdinand

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Marketing Form Date Field without Sundays

    Hi Ferdinand,

    Could the solution work for you?

    Regards,

    Clofly

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Marketing Form Date Field without Sundays

    Hi Ferdinand,

    Unfortunately, the date picker is built-in widget of browser, the only customization we can add to is setting its earliest and latest date to accept.

    (It is "date" type input element.)

    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date

    Therefore, the only option for us is to inject a custom date picker to the date field.

    However, due to Dynamics will always set date type field to date type input element, we have to create a single line text field to support custom date picker, 

    then triggering a plugin/flow on update of Contact and on change of the text field to sync string date to real date field.

    Here are steps:

    1. Add required libraries to source code of marketing page.(In its head tag.)

    * jquery.min.js

    * jquery-ui.js

    jquery-ui.css

    
        
        landing page
        
        
        
    

    pastedimage1605000101924v1.png

    2. After form render, inject date picker of jQueryUI to the custom single line text field.

    (We can get its id in HTML editor of marketing form, or with browser inspector.) 

    Because date picker of jQueryUI is supported to disable specific dates.

    pastedimage1605000421114v2.png

    3. Now in marketing form, Sunday has been disabled in calendar.

    pastedimage1605000501913v3.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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans